Class: Mobility::Backends::ActiveRecord::Hstore

Inherits:
PgHash
  • Object
show all
Defined in:
lib/mobility/backends/active_record/hstore.rb

Backend Accessors collapse

Class Method Summary collapse

Methods included from Mobility::Backends::ActiveRecord

included

Class Method Details

.build_node(attr, locale) ⇒ Mobility::Plugins::Arel::Nodes::Hstore

Returns Arel node for value of attribute key on hstore column.

Parameters:

  • attr (String)

    Attribute name

  • locale (Symbol)

    Locale

Returns:



29
30
31
32
# File 'lib/mobility/backends/active_record/hstore.rb', line 29

def self.build_node(attr, locale)
  column_name = column_affix % attr
  Plugins::Arel::Nodes::Hstore.new(model_class.arel_table[column_name], build_quoted(locale))
end

Instance Method Details

#read(locale, options = {}) ⇒ Object

Gets the translated value for provided locale from configured backend.

Parameters:

  • locale (Symbol)

    Locale to read

Returns:

  • (Object)

    Value of translation



# File 'lib/mobility/backends/active_record/hstore.rb', line 15

#write(locale, value, options = {}) ⇒ Object

Updates translation for provided locale without calling backend’s methods to persist the changes.

Parameters:

  • locale (Symbol)

    Locale to write

  • value (Object)

    Value to write

Returns:

  • (Object)

    Updated value



20
21
22
# File 'lib/mobility/backends/active_record/hstore.rb', line 20

def write(locale, value, options = {})
  super(locale, value && value.to_s, **options)
end