serialize_attributes 1.0.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 9264e3f62465ae9a4a27bf3afa14fa9cd516d14eab7b93e316c56d6cfb88ab4b
4
- data.tar.gz: 69bf1f4d1ccf209aabee4bb0ee5f128cc6ff93c3bb59dbbe295b39517c2cd5d7
3
+ metadata.gz: fcfd75fcff7e883cb0063752bb35de287b4683c59e0029bf654d77b0e67b7ec0
4
+ data.tar.gz: adc7cc26ba5b6dca8b543a2a33960419c66cd37149a5e759bdfc820f131fbe60
5
5
  SHA512:
6
- metadata.gz: 045a9d1d63e862b7eadb8372d68c002ae2c1c6cf32b00157c5c97d9970012f3c82c5d944a4cc55a632a693c7241875e9355953586d23d262f9355f61f1afc3bc
7
- data.tar.gz: d9992e49647e63d28b44d5c29e2c74936e7ee1fc305243c92bed744d579142c05c0475c26ce976cbce079f4ba29a67a48cd2cbd43729872daac337ecc45aefd7
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
- AttributeSet.new(raw_original_value) != new_value
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SerializeAttributes
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
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.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-17 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel