Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Json

Inherits:
Type
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/oid.rb

Instance Method Summary collapse

Methods inherited from Type

#type

Instance Method Details

#accessorObject


273
274
275
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 273

def accessor
  ActiveRecord::Store::StringKeyedHashAccessor
end

#type_cast(value) ⇒ Object


267
268
269
270
271
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 267

def type_cast(value)
  return if value.nil?

  ConnectionAdapters::PostgreSQLColumn.string_to_json value
end

#type_cast_for_write(value) ⇒ Object


260
261
262
263
264
265
# File 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb', line 260

def type_cast_for_write(value)
  # roundtrip to ensure uniform uniform types
  # TODO: This is not an efficient solution.
  stringified = ConnectionAdapters::PostgreSQLColumn.json_to_string(value)
  type_cast(stringified)
end