Sha256: 71d4bd75051e239996c4269b54c3a805103d8d4dfad13af5c39364a3261c7591

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true

module BusinessFlow
  # Fire ActiveSupport events for every step that's run and on errors
  class InstrumentedStepExecutor < InstrumentedExecutor
    protected

    def execute_step(step)
      i_name = event_name(step)
      i_payload = { flow: flow, step: step }.merge(::BusinessFlow::Instrument::ClassMethods.instrument_payload(flow))
      ActiveSupport::Notifications.instrument(i_name, i_payload) do |payload|
        payload[:step_result] = super
      end
      notify_errors(i_name, i_payload)
    end

    def step_event_name(step)
      "#{flow_name}.#{step.to_s.underscore}"
    end

    def event_name(step)
      "business_flow.step.#{step_event_name(step)}"
    end

  protected

    def flow_name
      @flow_name ||= flow.class.instrumentation_name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
business_flow-0.19.6 lib/business_flow/instrumented_step_executor.rb