activerecord_hstore_boolean 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf660dfc76f1a6ae5768c488557f400c823283f2
4
- data.tar.gz: ab6b61d71179b284bcaf0a89d461c047c14044de
3
+ metadata.gz: 070fab65620353977cb8c0d3202a27e3707c4ea7
4
+ data.tar.gz: 38dd0430a3f10575d10dd5dfbc439704f3ef905a
5
5
  SHA512:
6
- metadata.gz: 9fa9f31fddb813aa53c81bf408684134e59419a12bb67b78b5f805271da4c7be16fd8c3ee076a6f38eb86f7b621ffd076f807f3e8f6a063bd40db011f1e63fb3
7
- data.tar.gz: 5ed4c494eb215e23547e9f0519fd9f0264f614727d749be18db29f08de81fc62f8f3090233ac2f791d9d3ba9b3c81eb54347d82da6912e6cbca22b48cb4d3872
6
+ metadata.gz: cced38428ed113357f87d96e8e21264dfd667edf5d36ef6a8c612477bcb2dc8dfc8df22e4d6ecacd6da605f6ea2ef4d9c81c371c0092e9d80347621f0de70f7d
7
+ data.tar.gz: 87a2bb45a463e67b489c0071546f4018470763020707c502f7e9c702cf4d96937ebac1c4aa4355f98ff24939dce4163e34098d84b1b934d83400e2b166d13823
@@ -9,18 +9,18 @@ module ActiverecordHstoreBoolean
9
9
 
10
10
  module ClassMethods
11
11
  def hstore_boolean_values(attr_name, *keys)
12
- keys.map!(&:to_sym)
12
+ keys.map!(&:to_s)
13
13
  before_save "normalize_#{attr_name}_boolean_values"
14
14
 
15
15
  define_method("normalize_#{attr_name}_boolean_values") do
16
- self[attr_name].to_options!.each do |key, value|
17
- self[attr_name][key] = TRUE_VALUES.include?(value) ? STORED_TRUE_VALUE : STORED_FALSE_VALUE if keys.include?(key)
16
+ self[attr_name].each do |key, value|
17
+ self[attr_name][key] = TRUE_VALUES.include?(value) ? STORED_TRUE_VALUE : STORED_FALSE_VALUE if keys.include?(key.to_s)
18
18
  end
19
19
  end
20
20
 
21
21
  define_method(attr_name) do
22
- self[attr_name].to_options!.each do |key, value|
23
- self[attr_name][key] = value == STORED_TRUE_VALUE if keys.include?(key)
22
+ self[attr_name].each do |key, value|
23
+ self[attr_name][key] = value == STORED_TRUE_VALUE if keys.include?(key.to_s)
24
24
  end
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module ActiverecordHstoreBoolean
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -9,8 +9,8 @@ describe ActiverecordHstoreBoolean do
9
9
  it 'normalize true value' do
10
10
  product = Product.create(properties: { popular: true_value, color: 'white' })
11
11
  product.reload
12
- expect(product.properties[:popular]).to be_true
13
- expect(product.properties[:color]).to eq 'white'
12
+ expect(product.properties['popular']).to be_true
13
+ expect(product.properties['color']).to eq 'white'
14
14
  end
15
15
 
16
16
  end
@@ -18,7 +18,7 @@ describe ActiverecordHstoreBoolean do
18
18
  it 'normalize falue value' do
19
19
  product = Product.create(properties: { popular: 'false', color: 'white' })
20
20
  product.reload
21
- expect(product.properties[:popular]).to be_false
22
- expect(product.properties[:color]).to eq 'white'
21
+ expect(product.properties['popular']).to be_false
22
+ expect(product.properties['color']).to eq 'white'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_hstore_boolean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meck