Class: SpreeMobility::TranslationQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/spree_mobility/translation_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(mobility_backend_class) ⇒ TranslationQuery

Returns a new instance of TranslationQuery.

[View source]

3
4
5
# File 'lib/spree_mobility/translation_query.rb', line 3

def initialize(mobility_backend_class)
  @mobility_backend_class = mobility_backend_class
end

Instance Method Details

#add_joins(search_scope) ⇒ Object

[View source]

7
8
9
10
11
12
13
14
# File 'lib/spree_mobility/translation_query.rb', line 7

def add_joins(search_scope)
  fallback_locales.each do |locale|
    search_scope =
      @mobility_backend_class.
      send(:join_translations, search_scope, locale, ::Arel::Nodes::OuterJoin)
  end
  search_scope
end

#col_name(attr) ⇒ Object

[View source]

16
17
18
19
20
21
22
# File 'lib/spree_mobility/translation_query.rb', line 16

def col_name(attr)
  select_columns = []
  fallback_locales.each do |locale|
    select_columns << "#{table_alias(locale)}.#{attr}"
  end
  "COALESCE(#{select_columns.join(',')})"
end