Class: Catalog::UpdateCatalog
- Inherits:
-
BaseService
- Object
- BaseService
- Catalog::UpdateCatalog
- Defined in:
- app/services/catalog/update_catalog.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ UpdateCatalog
constructor
A new instance of UpdateCatalog.
- #process(catalog, catalog_params) ⇒ Object
Methods inherited from BaseService
#log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger
Constructor Details
#initialize(options = {}) ⇒ UpdateCatalog
Returns a new instance of UpdateCatalog.
8 9 10 11 12 |
# File 'app/services/catalog/update_catalog.rb', line 8 def initialize(={}) @synchronize_catalog_price_service = [:synchronize_catalog_price_service] || Catalog::SynchronizeCatalogPrices.new @validate_catalog_items_service = [:validate_catalog_items] || Catalog::ValidateCatalogItems.new super() end |
Instance Method Details
#process(catalog, catalog_params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/catalog/update_catalog.rb', line 14 def process(catalog, catalog_params) = [] attributes_before = catalog.attributes if catalog.update(catalog_params) << "Catalog #{catalog.id} #{catalog.name} updated" handle_catalog_item_constraints(catalog, attributes_before, ) Result.new(catalog: catalog, catalog_updated: true, messages: ) else Result.new(catalog: catalog, catalog_updated: false, messages: catalog.errors.) end end |