class BusinessFlow::InstrumentedExecutor

Fire ActiveSupport events for every step that's run and on errors

Public Instance Methods

call() click to toggle source
Calls superclass method BusinessFlow::DefaultStepExecutor#call
# File lib/business_flow/instrumented_executor.rb, line 4
def call
  name = flow_event_name
  payload = { flow: flow }
  ActiveSupport::Notifications.instrument(name, payload) do
    super
  end
  notify_errors(name, payload)
end

Protected Instance Methods

flow_event_name() click to toggle source
# File lib/business_flow/instrumented_executor.rb, line 24
def flow_event_name
  @flow_event_name ||= flow.class.event_name
end
flow_name() click to toggle source
# File lib/business_flow/instrumented_executor.rb, line 20
def flow_name
  @flow_name ||= flow.class.instrumentation_name
end
notify_errors(name, payload) click to toggle source
# File lib/business_flow/instrumented_executor.rb, line 15
def notify_errors(name, payload)
  return unless flow.errors?
  ActiveSupport::Notifications.publish(name + '.error', payload)
end