activerecord-bixformer 0.4.12 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a3541585aa33622c218ca37f1f491abdad35b18
4
- data.tar.gz: 72cf94a236a2159812d76ded6bb1e9dc26db63af
3
+ metadata.gz: 18a1d0fe7e88548ee68e8c40d795a239b931195c
4
+ data.tar.gz: fc576daa90e40135a7c5c5fc8c5f912f4e55a800
5
5
  SHA512:
6
- metadata.gz: 32ca63f4725f5f5ddb266c4421461d6f9b31d438cae03c4426bca8f62fd418ef7e57bd9331cc57cd787ab09c3b65eccefad58f5d6b6800e5c0a7de66aa057d49
7
- data.tar.gz: ab63c757e9d0bb65341684192302853b976dd9158c5899b686666c1f264e59bbea59a3a46b0f7af62c1438e765385ab6bf2742ee212078302043c44007ff6ae3
6
+ metadata.gz: 5896a50008272eba1bbf62e5476a0321ab337110fa5fe9c388f9f20301d7c0c2e3c0c7a5cdfa4395c603074829ffa5594963f882f047fb65d83e20ac8151624b
7
+ data.tar.gz: 7d4afa28dd6db8883d4bd3e30840f5bb07efb5fe126f1e6be273a7d8e894dd400f39edb0f9b323ceb1a6f8d15536ef925cebbb2ae0022ba116625d1eb7eef247
@@ -87,17 +87,30 @@ module ActiveRecord
87
87
  arr = []
88
88
  hash = {}
89
89
 
90
+ symbolizer = -> (value) do
91
+ case value
92
+ when ::Hash
93
+ value.map { |k, v| [k.to_sym, symbolizer.call(v)]}.to_h
94
+ when ::Array
95
+ value.map { |v| symbolizer.call(v) }
96
+ when ::String
97
+ value.to_sym
98
+ else
99
+ value
100
+ end
101
+ end
102
+
90
103
  @attributes.each do |attr|
91
104
  attr_should_be_included = attr.should_be_included
92
105
 
93
106
  next unless attr_should_be_included
94
107
 
95
108
  if attr_should_be_included.is_a?(::Hash)
96
- hash.merge!(attr_should_be_included)
109
+ hash.merge!(symbolizer.call(attr_should_be_included))
97
110
  elsif attr_should_be_included.is_a?(::Array)
98
- arr.push *attr_should_be_included
111
+ arr.push *symbolizer.call(attr_should_be_included)
99
112
  else
100
- arr.push attr_should_be_included
113
+ arr.push symbolizer.call(attr_should_be_included)
101
114
  end
102
115
  end
103
116
 
@@ -105,9 +118,9 @@ module ActiveRecord
105
118
  assoc_should_be_included = assoc.should_be_included
106
119
 
107
120
  if assoc_should_be_included.empty?
108
- arr.push assoc.name
121
+ arr.push assoc.name.to_sym
109
122
  else
110
- hash[assoc.name] = assoc_should_be_included
123
+ hash[assoc.name.to_sym] = assoc_should_be_included
111
124
  end
112
125
  end
113
126
 
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Bixformer
3
- VERSION = "0.4.12"
3
+ VERSION = "0.4.13"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-bixformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroaki Otsu