Class: ItemTranslationWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/item_translation_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/item_translation_worker.rb', line 7

def perform(options = {})
  item_id = options['item_id']
  locales = options['locales'].presence
  reset_previous_values = options['reset_previous_values'].to_b
  if item_id && (item = Item.find(item_id))
    if options['specs'].to_b
      item.auto_translate_product_specifications(reset_previous_values: reset_previous_values, locales: locales)
      item.update_rendered_product_specifications
    end
    if options['attributes'].to_b
      item.auto_translate_attributes(reset_previous_values: reset_previous_values, locales: locales)
    end
  end
end