Class: Udongo::FlexibleContent::DuplicateLocale
- Inherits:
-
Object
- Object
- Udongo::FlexibleContent::DuplicateLocale
- Defined in:
- lib/udongo/flexible_content/duplicate_locale.rb
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(object, source_locale, destination_locale) ⇒ DuplicateLocale
constructor
A new instance of DuplicateLocale.
Constructor Details
#initialize(object, source_locale, destination_locale) ⇒ DuplicateLocale
Returns a new instance of DuplicateLocale.
4 5 6 7 8 |
# File 'lib/udongo/flexible_content/duplicate_locale.rb', line 4 def initialize(object, source_locale, destination_locale) @object = object @source_locale = source_locale @destination_locale = destination_locale end |
Instance Method Details
#execute! ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/udongo/flexible_content/duplicate_locale.rb', line 10 def execute! check_for_flexible_content! check_for_different_locales! ActiveRecord::Base.transaction do clear_destination_content! @object.content_rows.by_locale(@source_locale).each do |source_row| new_row = duplicate_row(source_row) source_row.columns.each do |source_column| duplicate_column(new_row, source_column) end end end end |