Skip to Content Skip to Search

class ActiveRecord::Type::Json

Inherits From

Constants

ActiveSupport::JSON::Encoding.json_encoder.new(escape: false)

Public instance methods

Source code GitHub
# File activerecord/lib/active_record/type/json.rb, line 29
def accessor
  ActiveRecord::Store::StringKeyedHashAccessor
end
Source code GitHub
# File activerecord/lib/active_record/type/json.rb, line 25
def changed_in_place?(raw_old_value, new_value)
  deserialize(raw_old_value) != new_value
end
Source code GitHub
# File activerecord/lib/active_record/type/json.rb, line 14
def deserialize(value)
  return value unless value.is_a?(::String)
  ActiveSupport::JSON.decode(value) rescue nil
end
Source code GitHub
# File activerecord/lib/active_record/type/json.rb, line 21
def serialize(value)
  JSON_ENCODER.encode(value) unless value.nil?
end
Source code GitHub
# File activerecord/lib/active_record/type/json.rb, line 10
def type
  :json
end

Definition files