Class: Mobility::Backends::ActiveRecord::Json

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

Backend Accessors collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mobility::Backends::ActiveRecord

included

Class Method Details

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

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

Parameters:

  • attr (String)

    Attribute name

  • locale (Symbol)

    Locale

Returns:



37
38
39
40
# File 'lib/mobility/backends/active_record/json.rb', line 37

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

Instance Method Details

#read(locale, **options) ⇒ String, ...

Note:

Translation may be string, integer or boolean-valued since value is stored on a JSON hash.

Returns Value of translation.

Parameters:

  • locale (Symbol)

    Locale to read

  • options (Hash)

Returns:

  • (String, Integer, Boolean)

    Value of translation



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

#write(locale, value, **options) ⇒ String, ...

Note:

Translation may be string, integer or boolean-valued since value is stored on a JSON hash.

Returns Updated value.

Parameters:

  • locale (Symbol)

    Locale to write

  • value (String, Integer, Boolean)

    Value to write

  • options (Hash)

Returns:

  • (String, Integer, Boolean)

    Updated value



# File 'lib/mobility/backends/active_record/json.rb', line 24