Class: Spree::Themes::Duplicator
- Inherits:
-
Object
- Object
- Spree::Themes::Duplicator
- Defined in:
- app/services/spree/themes/duplicator.rb
Instance Method Summary collapse
- #duplicate ⇒ Object
-
#initialize(theme) ⇒ Duplicator
constructor
A new instance of Duplicator.
Constructor Details
#initialize(theme) ⇒ Duplicator
Returns a new instance of Duplicator.
4 5 6 |
# File 'app/services/spree/themes/duplicator.rb', line 4 def initialize(theme) @theme = theme end |
Instance Method Details
#duplicate ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/spree/themes/duplicator.rb', line 8 def duplicate duplicated_theme = @theme.dup duplicated_theme.duplicating = true duplicated_theme.default = false duplicated_theme.ready = false duplicated_theme.name = generate_new_name(@theme.name) duplicated_theme.save! # We need to duplicate files, pages and sections in the background Spree::Themes::DuplicateComponentsJob.set(wait: 5.seconds).perform_later(@theme.id, duplicated_theme.id) duplicated_theme end |