Module: ActiveModel::Type::Helpers::Mutable
- Included in:
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array, ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Hstore, ActiveRecord::ConnectionAdapters::PostgreSQL::OID::LegacyPoint, ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Point, ActiveRecord::Encryption::EncryptedAttributeType, ActiveRecord::Type::Json, ActiveRecord::Type::Serialized
- Defined in:
- activemodel/lib/active_model/type/helpers/mutable.rb
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
raw_old_value
will be the ‘_before_type_cast` version of the value (likely a string). - #immutable_value(value) ⇒ Object
Instance Method Details
#cast(value) ⇒ Object
11 12 13 |
# File 'activemodel/lib/active_model/type/helpers/mutable.rb', line 11 def cast(value) deserialize(serialize(value)) end |
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
raw_old_value
will be the ‘_before_type_cast` version of the value (likely a string). new_value
will be the current, type cast value.
18 19 20 |
# File 'activemodel/lib/active_model/type/helpers/mutable.rb', line 18 def changed_in_place?(raw_old_value, new_value) raw_old_value != serialize(new_value) end |
#immutable_value(value) ⇒ Object
7 8 9 |
# File 'activemodel/lib/active_model/type/helpers/mutable.rb', line 7 def immutable_value(value) value.deep_dup.freeze end |