Class: ActiveRecord::Type::Json
Instance Attribute Summary
#limit, #precision, #scale
Instance Method Summary
collapse
#cast, #immutable_value
#==, #as_json, #assert_valid_value, #binary?, #cast, #changed?, #force_equality?, #hash, #immutable_value, #initialize, #map, #serializable?, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Instance Method Details
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
21
22
23
|
# File 'activerecord/lib/active_record/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 'activerecord/lib/active_record/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 'activerecord/lib/active_record/type/json.rb', line 17
def serialize(value)
ActiveSupport::JSON.encode(value) unless value.nil?
end
|
8
9
10
|
# File 'activerecord/lib/active_record/type/json.rb', line 8
def type
:json
end
|