Class: Locomotive::TranslationService

Inherits:
Struct
  • Object
show all
Defined in:
app/services/locomotive/translation_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject

Returns the value of attribute account

Returns:

  • (Object)

    the current value of account


3
4
5
# File 'app/services/locomotive/translation_service.rb', line 3

def 
  @account
end

#siteObject

Returns the value of attribute site

Returns:

  • (Object)

    the current value of 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(options = {})
  query       = site.translations.ordered
  keywords    = prepare_keywords_statement(options[:q])
  completion  = prepare_completion_statement(options[:filter_by])

  # filtering
  query = if completion then query.and(*keywords, *completion) else query.where(keywords) end

  # pagination
  query
    .page(options[:page] || 1)
    .per(options[: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 =  if 
    translation.save
  end
end