Class: CatalogItem::PriceUpdatedHandler
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- CatalogItem::PriceUpdatedHandler
- Includes:
- RailsEventStore::AsyncHandler
- Defined in:
- app/subscribers/catalog_item/price_updated_handler.rb
Overview
Pub/sub subscriber: price updated handler.
Instance Method Summary collapse
Instance Method Details
#perform(event) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/subscribers/catalog_item/price_updated_handler.rb', line 9 def perform(event) data = event.data price_was = data[:price_was] price_now = data[:price_now] return if price_was == price_now catalog_item = CatalogItem.find(data[:catalog_item_id]) Rails.logger.info "CatalogItem::PriceUpdatedHandler: price change for #{data[:catalog_item_id]} from #{price_was} to #{price_now}" catalog_item.dependent_catalog_items.each(&:item_specs_or_price_updated) catalog_item. rescue StandardError => e ErrorReporting.error(e) raise end |