Class: EmbeddedLocalization::Storage::Json

Inherits:
ActiveRecord::Type::Json
  • Object
show all
Defined in:
lib/embedded_localization/storage/json.rb

Overview

ActiveRecord attribute type for a json or jsonb i18n column.

The column holds => {"name" => "...", "de" => ...}; in Ruby the gem works with Symbol keys on both levels, so this type converts the keys whenever a value comes from the database. Assignment goes through the same conversion: ActiveRecord::Type::Json includes ActiveModel::Type::Helpers::Mutable, whose cast(value) is deserialize(serialize(value)).

Instance Method Summary collapse

Instance Method Details

#deserialize(value) ⇒ Object



10
11
12
# File 'lib/embedded_localization/storage/json.rb', line 10

def deserialize(value)
  symbolize_keys(super)
end