Class: Ecm::Cms::AddHomepagesService
- Inherits:
-
Itsf::Services::V2::Service::Base
- Object
- Itsf::Services::V2::Service::Base
- Ecm::Cms::AddHomepagesService
- Defined in:
- app/services/ecm/cms/add_homepages_service.rb
Instance Attribute Summary collapse
-
#locales ⇒ Object
Returns the value of attribute locales.
Instance Method Summary collapse
- #do_work ⇒ Object
-
#initialize(attributes = {}) ⇒ AddHomepagesService
constructor
A new instance of AddHomepagesService.
Constructor Details
#initialize(attributes = {}) ⇒ AddHomepagesService
Returns a new instance of AddHomepagesService.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/ecm/cms/add_homepages_service.rb', line 7 def initialize(attributes = {}) attributes.reverse_merge!({ locales: I18n.available_locales }) attributes[:locales].try(:reject!, &:blank?) super(attributes) @all_pages = [] @already_existent_pages = [] @failed_pages = [] @created_pages = [] end |
Instance Attribute Details
#locales ⇒ Object
Returns the value of attribute locales.
3 4 5 |
# File 'app/services/ecm/cms/add_homepages_service.rb', line 3 def locales @locales end |
Instance Method Details
#do_work ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/services/ecm/cms/add_homepages_service.rb', line 19 def do_work say "Environment: #{Rails.env}" respond unless valid? create_homepages warn("Skipped #{@already_existent_pages.size} already existent pages for locales: #{@already_existent_pages.map(&:locale).join(', ')}", indent: 1) if @already_existent_pages.any? info("Added #{@created_pages.size} new home pages for locales: #{@created_pages.map(&:locale).join(', ')}", indent: 1) warn("Failed adding #{@failed_pages.size} new home pages for locales: #{@failed_pages.map(&:locale).join(', ')}", indent: 1) if @failed_pages.any? respond end |