Class: ActiveEntity::Type::Json
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- ActiveEntity::Type::Json
- Includes:
- ActiveModel::Type::Helpers::Mutable
- Defined in:
- lib/active_entity/type/json.rb
Instance Method Summary collapse
- #accessor ⇒ Object
- #changed_in_place?(raw_old_value, new_value) ⇒ Boolean
- #deserialize(value) ⇒ Object
- #serialize(value) ⇒ Object
- #type ⇒ Object
Instance Method Details
#accessor ⇒ Object
25 26 27 |
# File 'lib/active_entity/type/json.rb', line 25 def accessor ActiveEntity::Store::StringKeyedHashAccessor end |
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
21 22 23 |
# File 'lib/active_entity/type/json.rb', line 21 def changed_in_place?(raw_old_value, new_value) deserialize(raw_old_value) != new_value end |
#deserialize(value) ⇒ Object
12 13 14 15 |
# File 'lib/active_entity/type/json.rb', line 12 def deserialize(value) return value unless value.is_a?(::String) ActiveSupport::JSON.decode(value) rescue nil end |
#serialize(value) ⇒ Object
17 18 19 |
# File 'lib/active_entity/type/json.rb', line 17 def serialize(value) ActiveSupport::JSON.encode(value) unless value.nil? end |
#type ⇒ Object
8 9 10 |
# File 'lib/active_entity/type/json.rb', line 8 def type :json end |