Class: TranslationJobs::AutoTranslateJob

Inherits:
Object
  • Object
show all
Defined in:
lib/has_many_translations/translation_jobs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AutoTranslateJob

Returns a new instance of AutoTranslateJob.



19
20
21
22
23
24
# File 'lib/has_many_translations/translation_jobs.rb', line 19

def initialize(options)
  @translated_id = options["translated_id"]||options[:translated_id]
  @translated_type =  options["translated_type"]||options[:translated_type]
  @origin_locale =  options["origin_locale"]||options[:origin_locale]
  @destination_locale = options["destination_locale"]|| options[:destination_locale]
end

Instance Attribute Details

#destination_localeObject

Returns the value of attribute destination_locale.



17
18
19
# File 'lib/has_many_translations/translation_jobs.rb', line 17

def destination_locale
  @destination_locale
end

#origin_localeObject

Returns the value of attribute origin_locale.



17
18
19
# File 'lib/has_many_translations/translation_jobs.rb', line 17

def origin_locale
  @origin_locale
end

#translated_idObject

Returns the value of attribute translated_id.



17
18
19
# File 'lib/has_many_translations/translation_jobs.rb', line 17

def translated_id
  @translated_id
end

#translated_typeObject

Returns the value of attribute translated_type.



17
18
19
# File 'lib/has_many_translations/translation_jobs.rb', line 17

def translated_type
  @translated_type
end

Instance Method Details

#perform(options = nil) ⇒ Object



26
27
28
29
# File 'lib/has_many_translations/translation_jobs.rb', line 26

def perform(options = nil)
  translatable = Kernel.const_get(@translated_type).find(@translated_id)
  translatable.update_all_attributes_translation(@destination_locale, @origin_locale)
end