Class: Locomotive::TranslationService
- Inherits:
-
Struct
- Object
- Struct
- Locomotive::TranslationService
- Defined in:
- app/services/locomotive/translation_service.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account
3 4 5 |
# File 'app/services/locomotive/translation_service.rb', line 3 def account @account end |
#site ⇒ Object
Returns the value of attribute site
3 4 5 |
# File 'app/services/locomotive/translation_service.rb', line 3 def site @site end |
Instance Method Details
#all(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/locomotive/translation_service.rb', line 5 def all( = {}) query = site.translations.ordered keywords = prepare_keywords_statement([:q]) completion = prepare_completion_statement([:filter_by]) # filtering query = if completion then query.and(*keywords, *completion) else query.where(keywords) end # pagination query .page([:page] || 1) .per([:per_page] || Locomotive.config.ui[:per_page]) end |
#bulk_destroy(ids) ⇒ Object
27 28 29 30 31 32 |
# File 'app/services/locomotive/translation_service.rb', line 27 def bulk_destroy(ids) site.translations.where(:id.in => ids).map do |translation| translation.destroy translation._id end end |
#update(translation, values) ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/services/locomotive/translation_service.rb', line 19 def update(translation, values) translation.tap do translation.values = values translation.updated_by = account if account translation.save end end |