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



16
17
18
# File 'lib/mobility/backends/active_record.rb', line 16

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



32
33
34
# File 'lib/mobility/backends/active_record.rb', line 32

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:



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

def build_node(_attr, _locale)
  raise NotImplementedError
end