Class: Mobility::Backends::ActiveRecord::Jsonb

Inherits:
PgHash
  • Object
show all
Defined in:
lib/mobility/backends/active_record/jsonb.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::Jsonb

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/jsonb.rb', line 37

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

Instance Method Details

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

Note:

Translation may be any json type, but querying will only work on string-typed values.

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/jsonb.rb', line 15

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

Note:

Translation may be any json type, but querying will only work on string-typed values.

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/jsonb.rb', line 24