Class: SpreeMobility::TranslationQuery
- Inherits:
-
Object
- Object
- SpreeMobility::TranslationQuery
- Defined in:
- lib/spree_mobility/translation_query.rb
Instance Method Summary collapse
- #add_joins(search_scope) ⇒ Object
- #col_name(attr) ⇒ Object
-
#initialize(mobility_backend_class) ⇒ TranslationQuery
constructor
A new instance of TranslationQuery.
Constructor Details
permalink #initialize(mobility_backend_class) ⇒ TranslationQuery
Returns a new instance of TranslationQuery.
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
permalink #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 |
permalink #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 |