store_attribute 2.1.1 → 2.2.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: 34f29a54cc5ccce123dd195448e665f646c8074d8bf4fefa72a3eec1c18a94bc
4
- data.tar.gz: 3deb3c7cd449df71ee289e7967864db8c6e223fdc6fb0f912b1a919560a6c991
3
+ metadata.gz: afa3af4ac1b9c521e3547dffef96b70bf2b0d3c900ef2601136b2eb7d3023ea8
4
+ data.tar.gz: 7aa3033868705bcff1cdf90a9533c0b0cc77f13e88380d7d7f1cca2a5327e50b
5
5
  SHA512:
6
- metadata.gz: 739f05b7c5c44430560a3392686c2f1ccc536fb4a6f529b56d567935667e10a96165de00962d89c91b5bcb8d12704fd2b475beeb5164507bc007fd3285996958
7
- data.tar.gz: a147f51114c74db06596d2068c4ef83db35785519211a15e1dc0f345540abafc826badd75fd877beb72b5f1d4c04b34f47ea6938ac9a432e8f65f6d821985d44
6
+ metadata.gz: c97a1ecbe6e3903b1acaca20bdac15a1e105035046270aa00d93a32068e313ac20fcb6631af78c27067f2ff87c855e32b8b6e42e7a5c42a3339938cf76c4e8ef
7
+ data.tar.gz: 1bc2ca346cb6356373d9a9fa99d3fc12f0571989a535096920c740b138fd38027cda366d5513c47e7788ce55698daa658b890dcfd7f647fbc79edcd14ee29a12
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.2.0 (2026-07-17)
6
+
7
+ - Add regression coverage for store key dirty-tracking methods (`saved_change_to_KEY?`, `KEY_changed?`, `KEY_was`, `KEY_change`, `KEY_before_last_save`), which rely on `TypedStore` delegating `#get` to the underlying store accessor (fixed in 2.0.1). ([@palkan][])
8
+
9
+ - Defer patching Active Record via `ActiveSupport.on_load(:active_record)` so requiring the gem no longer force-loads the JSON column type before app initializers run. ([@MattyMc](https://github.com/MattyMc))
10
+
11
+ - Fix Rails 8.2 compatibility (named store accessors module). ([@palkan][])
12
+
13
+ - Cast values coming from attribute defaults ([@honeyryderchuck][]).
14
+
5
15
  ## 2.1.1 (2026-01-13)
6
16
 
7
17
  - Fix defining store attributes after schema loading. ([@palkan][])
@@ -272,6 +272,19 @@ module ActiveRecord
272
272
  end
273
273
  end
274
274
  end
275
+
276
+ unless method_defined?(:_store_accessors_module)
277
+ # Rails 8.2 introduced named accessors module
278
+ def _store_accessors_module
279
+ if const_defined?(:GeneratedStoreMethods, false)
280
+ const_get(:GeneratedStoreMethods, false)
281
+ else
282
+ mod = const_set(:GeneratedStoreMethods, Module.new)
283
+ include mod # rubocop:disable Layout/EmptyLinesAfterModuleInclusion
284
+ mod
285
+ end
286
+ end
287
+ end
275
288
  end
276
289
  end
277
290
  end
@@ -52,7 +52,7 @@ module ActiveRecord
52
52
  if hash.key?(key)
53
53
  hash[key] = type.deserialize(hash[key])
54
54
  elsif fallback_to_default?(key)
55
- hash[key] = built_defaults[key]
55
+ hash[key] = type.deserialize(built_defaults[key])
56
56
  end
57
57
  end
58
58
  hash
@@ -82,7 +82,7 @@ module ActiveRecord
82
82
  if hash.key?(key)
83
83
  hash[key] = type.cast(hash[key])
84
84
  elsif fallback_to_default?(key)
85
- hash[key] = built_defaults[key]
85
+ hash[key] = type.cast(built_defaults[key])
86
86
  end
87
87
  end
88
88
  hash
@@ -1,3 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "store_attribute/active_record/store"
3
+ require "active_support/lazy_load_hooks"
4
+
5
+ ActiveSupport.on_load(:active_record) do
6
+ require "store_attribute/active_record/store"
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreAttribute # :nodoc:
4
- VERSION = "2.1.1"
4
+ VERSION = "2.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.0.5
32
+ version: 0.2.0
33
33
  type: :development
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.5
39
+ version: 0.2.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
42
42
  requirement: !ruby/object:Gem::Requirement