activerecord-typedstore 1.3.2 → 1.4.0

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
  SHA256:
3
- metadata.gz: bdeb6337150bcfbc1307433960078b4ee4fa86930eea89ed1e27214df82b6d1a
4
- data.tar.gz: 883fc7c802f2d86ca5a5c18133a75b8759907de917a938d765b3f55852338170
3
+ metadata.gz: 17f01f8701f6af429d7fb15bfbcf9cf202f1d82cbe0f6878aa4a503ed69fc0e8
4
+ data.tar.gz: e5e1dd4100a034b074fe2682e485ae1365c8bcbe9c4bb7bc96f697a5042c0f62
5
5
  SHA512:
6
- metadata.gz: 989ac79c84da4898c175da31cef578c576396987c7356093430e116089e27c377f561f05a53872bd0adfb79c4ee4deae795f8d0ef0e67bc1b4f461ef04790e1b
7
- data.tar.gz: a7f1e9fb20c79d5acd321140aad66d345c058155f2722d2afc9b25247615428b0286c8040d5c2a432a2f2d05b5a2666d2c773dbc56dcdfba9113d39f13901593
6
+ metadata.gz: f1703f9023ab91ac749d74335276a0824d3072060eac8a68270f2b52e41198dfeebecffd54738cd4b097fe97948371479e2db1c1fa8ebc30ca07eeeaf63bac91
7
+ data.tar.gz: 8e48b1f137a374053092ccf52f3411759fcf421d1e4d8cf8b7f47b3c25d935aaf958f568ee35423381171aca879bf68a7b943493cf4947a8d3af19f66d54616f
@@ -23,8 +23,8 @@ module ActiveRecord::TypedStore
23
23
  define_method(method) do |value|
24
24
  return if value.nil?
25
25
 
26
- if value.respond_to?(:to_h)
27
- super(value.to_h)
26
+ if value.respond_to?(:to_hash)
27
+ super(value.to_hash)
28
28
  else
29
29
  raise ArgumentError, "ActiveRecord::TypedStore expects a hash as a column value, #{value.class} received"
30
30
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module TypedStore
5
- VERSION = '1.3.2'
5
+ VERSION = '1.4.0'
6
6
  end
7
7
  end
@@ -723,6 +723,11 @@ shared_examples 'a store' do |retain_type = true, settings_type = :text|
723
723
  expect(model.explicit_settings[:signup][:counter]).to be_nil
724
724
  end
725
725
 
726
+ it 'coerce hashes to HashWithIndifferentAccess' do # this is actually Rails behavior
727
+ model.signup[:metadata] = { "signed_up_at" => Time.now }
728
+ expect(model.signup[:metadata]).to be_a ActiveSupport::HashWithIndifferentAccess
729
+ end
730
+
726
731
  end
727
732
  end
728
733
 
@@ -841,6 +846,11 @@ describe YamlTypedStoreModel do
841
846
  it_should_behave_like 'any model'
842
847
  it_should_behave_like 'a store'
843
848
  it_should_behave_like 'a model supporting arrays'
849
+
850
+ it 'nested hashes are not serialized as HashWithIndifferentAccess' do
851
+ model = described_class.create!
852
+ expect(model.settings_before_type_cast).not_to include('HashWithIndifferentAccess')
853
+ end
844
854
  end
845
855
 
846
856
  describe JsonTypedStoreModel do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-typedstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.1.4
193
+ rubygems_version: 3.1.2
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: Add type casting and full method attributes support to АctiveRecord store