serialize_attributes 1.0.0 → 1.0.1
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/lib/serialize_attributes/store.rb +13 -1
- data/lib/serialize_attributes/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: fcfd75fcff7e883cb0063752bb35de287b4683c59e0029bf654d77b0e67b7ec0
|
4
|
+
data.tar.gz: adc7cc26ba5b6dca8b543a2a33960419c66cd37149a5e759bdfc820f131fbe60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f160a8efe020f2d47d385f3c2ea76149adcf2d6eff06dd6d9b49e08e0684e7fa1cbcd4abb7e6c8f8ea3d25cebed1c888a2aa7bbb42d4a7fff5f0c5ec30d08d67
|
7
|
+
data.tar.gz: a58b02f33d14bd4afa8202a7d69553377ecf2fc2b9b4c011fbc5fdf2ff8460628dc8675d8ad883bfedb98e810779597a3afbe4f01347a9014baa5189d0223afb
|
@@ -150,6 +150,18 @@ module SerializeAttributes
|
|
150
150
|
def deserialize(value)
|
151
151
|
Array.wrap(value).map { __getobj__.deserialize(_1) }
|
152
152
|
end
|
153
|
+
|
154
|
+
# For arrays of strings (the most common array type), the underlying Type::String in
|
155
|
+
# Rails won't do this check if the raw value isn't a String (and returns `nil`):
|
156
|
+
#
|
157
|
+
# def changed_in_place?(a, b)
|
158
|
+
# if a.is_a?(String)
|
159
|
+
# ...
|
160
|
+
#
|
161
|
+
# This means we have to override this check ourselves here.
|
162
|
+
def changed_in_place?(raw_old_value, new_value)
|
163
|
+
raw_old_value != new_value
|
164
|
+
end
|
153
165
|
end
|
154
166
|
|
155
167
|
class AttributeSet < ::ActiveModel::AttributeSet # :nodoc:
|
@@ -176,7 +188,7 @@ module SerializeAttributes
|
|
176
188
|
end
|
177
189
|
|
178
190
|
def changed_in_place?(raw_original_value, new_value)
|
179
|
-
|
191
|
+
(deserialize(raw_original_value) != new_value) || new_value.each_value.any?(&:changed_in_place?)
|
180
192
|
end
|
181
193
|
|
182
194
|
def serialize(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serialize_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaikio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|