active_typed_store 1.3.0 → 2.0.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 +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -7
- data/lib/active_typed_store/attrs.rb +25 -16
- data/lib/active_typed_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bbeb2d1b777327fdb95ee0864943128f702833b22bb67499e89d8508f2d99fd
|
4
|
+
data.tar.gz: e6c3263d53cad2ff342195ac01581039520cbe7ebb3622a47f3adaa6e2690110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17d199bc2b8421bc0efb370b145576d948236be298ea2ef80ef6e865a751130d8d5016bfb7e2f366202a55d062b80ba7b5e4494166086c15da3a65a9aec2c715
|
7
|
+
data.tar.gz: 6341dc95fdc95c2442eaf105297e153697ce9227b9d81993862b70c94f2d9e9449d5f1bb47a60ef39a2e5202e06e282168a95093cb18f9930c15a0c43b5b61ce
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -22,7 +22,7 @@ GIT
|
|
22
22
|
PATH
|
23
23
|
remote: .
|
24
24
|
specs:
|
25
|
-
active_typed_store (1.
|
25
|
+
active_typed_store (1.3.0)
|
26
26
|
activemodel
|
27
27
|
activerecord
|
28
28
|
activesupport
|
@@ -63,6 +63,11 @@ GEM
|
|
63
63
|
concurrent-ruby (~> 1.0)
|
64
64
|
dry-core (~> 1.0, < 2)
|
65
65
|
zeitwerk (~> 2.6)
|
66
|
+
dry-struct (1.6.0)
|
67
|
+
dry-core (~> 1.0, < 2)
|
68
|
+
dry-types (>= 1.7, < 2)
|
69
|
+
ice_nine (~> 0.11)
|
70
|
+
zeitwerk (~> 2.6)
|
66
71
|
dry-types (1.7.2)
|
67
72
|
bigdecimal (~> 3.0)
|
68
73
|
concurrent-ruby (~> 1.0)
|
@@ -72,6 +77,7 @@ GEM
|
|
72
77
|
zeitwerk (~> 2.6)
|
73
78
|
i18n (1.14.5)
|
74
79
|
concurrent-ruby (~> 1.0)
|
80
|
+
ice_nine (0.11.2)
|
75
81
|
json (2.7.2)
|
76
82
|
language_server-protocol (3.17.0.3)
|
77
83
|
logger (1.6.1)
|
@@ -131,8 +137,6 @@ GEM
|
|
131
137
|
rumoji (0.5.0)
|
132
138
|
securerandom (0.3.1)
|
133
139
|
sqlite3 (1.7.3-arm64-darwin)
|
134
|
-
sqlite3 (1.7.3-x86_64-darwin)
|
135
|
-
sqlite3 (1.7.3-x86_64-linux)
|
136
140
|
timeout (0.4.1)
|
137
141
|
tzinfo (2.0.6)
|
138
142
|
concurrent-ruby (~> 1.0)
|
@@ -140,14 +144,11 @@ GEM
|
|
140
144
|
zeitwerk (2.6.18)
|
141
145
|
|
142
146
|
PLATFORMS
|
143
|
-
arm64-darwin-21
|
144
|
-
arm64-darwin-23
|
145
147
|
arm64-darwin-24
|
146
|
-
x86_64-darwin-21
|
147
|
-
x86_64-linux
|
148
148
|
|
149
149
|
DEPENDENCIES
|
150
150
|
active_typed_store!
|
151
|
+
dry-struct
|
151
152
|
dry-types
|
152
153
|
priscilla!
|
153
154
|
rake (~> 13.0)
|
@@ -41,32 +41,41 @@ module ActiveTypedStore
|
|
41
41
|
end
|
42
42
|
|
43
43
|
private def reader(store_attribute, field, type, default)
|
44
|
-
ivar_prev
|
45
|
-
ivar_cache = :"@__ts_cache_#{field}"
|
44
|
+
ivar_prev = :"@__ts_prev_#{field}"
|
46
45
|
store_module.define_method(field) do
|
47
46
|
val = read_store_attribute(store_attribute, field)
|
48
|
-
return
|
47
|
+
return val if instance_variable_get(ivar_prev) == val.object_id && !val.nil?
|
49
48
|
|
50
|
-
|
49
|
+
is_default = false
|
50
|
+
casted_val =
|
51
51
|
if val.nil? && !default.nil?
|
52
|
+
is_default = true
|
53
|
+
default.dup
|
54
|
+
elsif type.respond_to?(:cast)
|
55
|
+
type.cast(val)
|
56
|
+
else
|
57
|
+
type[val]
|
58
|
+
end
|
59
|
+
|
60
|
+
return_val =
|
61
|
+
if casted_val.eql?(val)
|
62
|
+
val
|
63
|
+
else
|
52
64
|
is_changed = attribute_changed?(store_attribute)
|
53
|
-
self[store_attribute][field] = default.dup
|
54
65
|
|
55
|
-
|
56
|
-
|
66
|
+
# write cast val
|
67
|
+
self[store_attribute][field] = casted_val
|
68
|
+
|
69
|
+
# discard changes
|
70
|
+
if !is_changed && (val == casted_val || is_default)
|
71
|
+
@attributes.write_from_database(store_attribute, self[store_attribute].to_json).value[field]
|
57
72
|
else
|
58
|
-
|
59
|
-
@attributes.write_from_database(store_attribute, self[store_attribute]).value[field]
|
73
|
+
casted_val
|
60
74
|
end
|
61
|
-
elsif type.respond_to?(:cast)
|
62
|
-
casted = type.cast(val)
|
63
|
-
casted.eql?(val) ? val : casted
|
64
|
-
else
|
65
|
-
type[val]
|
66
75
|
end
|
67
76
|
|
68
|
-
instance_variable_set(ivar_prev,
|
69
|
-
|
77
|
+
instance_variable_set(ivar_prev, return_val.object_id)
|
78
|
+
return_val
|
70
79
|
end
|
71
80
|
end
|
72
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_typed_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ermolaev Andrey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-05-
|
11
|
+
date: 2025-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|