Class: SerializeAttributes::Store::ArrayWrapper
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SerializeAttributes::Store::ArrayWrapper
- Defined in:
- lib/serialize_attributes/store.rb
Overview
:nodoc:
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
For arrays of strings (the most common array type), the underlying Type::String in Rails won’t do this check if the raw value isn’t a String (and returns ‘nil`):.
- #deserialize(value) ⇒ Object
Instance Method Details
#cast(value) ⇒ Object
144 145 146 147 148 |
# File 'lib/serialize_attributes/store.rb', line 144 def cast(value) return [] if value.nil? Array(value) end |
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
For arrays of strings (the most common array type), the underlying Type::String in Rails won’t do this check if the raw value isn’t a String (and returns ‘nil`):
def changed_in_place?(a, b)
if a.is_a?(String)
...
This means we have to override this check ourselves here.
162 163 164 |
# File 'lib/serialize_attributes/store.rb', line 162 def changed_in_place?(raw_old_value, new_value) raw_old_value != new_value end |
#deserialize(value) ⇒ Object
150 151 152 |
# File 'lib/serialize_attributes/store.rb', line 150 def deserialize(value) Array.wrap(value).map { __getobj__.deserialize(_1) } end |