Module: Mobility::Backends::ActiveRecord::ClassMethods

Defined in:
lib/mobility/backends/active_record.rb

Instance Method Summary collapse

Instance Method Details

#[](name, locale) ⇒ Object

Parameters:

  • name (Symbol)

    Attribute name

  • locale (Symbol)

    Locale


12
13
14
# File 'lib/mobility/backends/active_record.rb', line 12

def [](name, locale)
  build_node(name.to_s, locale)
end

#apply_scope(relation, _predicate, _locale = Mobility.locale, invert: false) ⇒ ActiveRecord::Relation

Returns Relation with scope added.

Parameters:

  • relation (ActiveRecord::Relation)

    Relation to scope

  • predicate (Object)

    Arel predicate

  • locale (Symbol)

    (Mobility.locale) Locale

  • [Boolean] (Hash)

    a customizable set of options

Returns:

  • (ActiveRecord::Relation)

    Relation with scope added


28
29
30
# File 'lib/mobility/backends/active_record.rb', line 28

def apply_scope(relation, _predicate, _locale = Mobility.locale, invert: false)
  relation
end

#build_node(_attr, _locale) ⇒ Object

Returns Arel node for this translated attribute.

Parameters:

  • _attr (String)

    Attribute name

  • _locale (Symbol)

    Locale

Returns:

  • Arel node for this translated attribute

Raises:


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

def build_node(_attr, _locale)
  raise NotImplementedError
end