Class: LcpRuby::BackgroundJobs::Declarative::FireEventAction
- Inherits:
-
BaseAction
- Object
- BaseHandler
- BaseAction
- LcpRuby::BackgroundJobs::Declarative::FireEventAction
- Defined in:
- lib/lcp_ruby/background_jobs/declarative/fire_event_action.rb
Instance Attribute Summary
Attributes inherited from BaseHandler
Instance Method Summary collapse
Methods inherited from BaseAction
Methods inherited from BaseHandler
#attach_result!, #check_cancellation!, #flush_log!, #initialize, #log!, #params, #set_result_url!, #target_record, #triggered_by, #update_progress!
Constructor Details
This class inherits a constructor from LcpRuby::BackgroundJobs::BaseHandler
Instance Method Details
#perform ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lcp_ruby/background_jobs/declarative/fire_event_action.rb', line 5 def perform event_name = config["event"] raise JobError, "fire_event action requires an 'event' key" unless event_name.present? record = target_record if record Events::Dispatcher.dispatch( event_name: event_name, record: record, changes: {} ) log!("Fired event '#{event_name}' for #{execution.target_model}##{execution.target_id}", level: :info) else log!("Fired event '#{event_name}' (no target record)", level: :info) end end |