Class: Spotlight::CloneTranslatedPageFromLocale

Inherits:
Object
  • Object
show all
Defined in:
app/services/spotlight/clone_translated_page_from_locale.rb

Overview

A service class to encapsulate business logic around cloning and destroying translated pages

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale:, page:) ⇒ CloneTranslatedPageFromLocale

Returns a new instance of CloneTranslatedPageFromLocale.



10
11
12
13
# File 'app/services/spotlight/clone_translated_page_from_locale.rb', line 10

def initialize(locale:, page:)
  @locale = locale
  @page = page
end

Instance Attribute Details

#localeObject (readonly)

Returns the value of attribute locale.



8
9
10
# File 'app/services/spotlight/clone_translated_page_from_locale.rb', line 8

def locale
  @locale
end

#pageObject (readonly)

Returns the value of attribute page.



8
9
10
# File 'app/services/spotlight/clone_translated_page_from_locale.rb', line 8

def page
  @page
end

Class Method Details

.call(locale:, page:) ⇒ Object



15
16
17
# File 'app/services/spotlight/clone_translated_page_from_locale.rb', line 15

def self.call(locale:, page:)
  new(locale: locale, page: page).clone
end

Instance Method Details

#cloneObject



19
20
21
22
# File 'app/services/spotlight/clone_translated_page_from_locale.rb', line 19

def clone
  destroy
  page.clone_for_locale(locale)
end