Class: EmbeddedLocalization::Storage::Hstore
- Inherits:
-
ActiveRecord::Type::Value
- Object
- ActiveRecord::Type::Value
- EmbeddedLocalization::Storage::Hstore
- Includes:
- ActiveModel::Type::Helpers::Mutable
- Defined in:
- lib/embedded_localization/storage/hstore.rb
Overview
ActiveRecord attribute type for a PostgreSQL hstore i18n column.
hstore is a flat String => String map, so each translation is stored under the key "
Constant Summary collapse
- SEPARATOR =
'.'.freeze
Instance Method Summary collapse
- #changed_in_place?(raw_old_value, new_value) ⇒ Boolean
- #deserialize(value) ⇒ Object
- #serialize(value) ⇒ Object
- #type ⇒ Object
Instance Method Details
#changed_in_place?(raw_old_value, new_value) ⇒ Boolean
25 26 27 |
# File 'lib/embedded_localization/storage/hstore.rb', line 25 def changed_in_place?(raw_old_value, new_value) deserialize(raw_old_value) != new_value end |
#deserialize(value) ⇒ Object
17 18 19 |
# File 'lib/embedded_localization/storage/hstore.rb', line 17 def deserialize(value) nest(hstore.deserialize(value)) end |
#serialize(value) ⇒ Object
21 22 23 |
# File 'lib/embedded_localization/storage/hstore.rb', line 21 def serialize(value) hstore.serialize(flatten(value)) end |
#type ⇒ Object
13 14 15 |
# File 'lib/embedded_localization/storage/hstore.rb', line 13 def type :hstore end |