Sha256: b0903df110076f920ff4c746afda64b65be45685c4f973e00ff080042a3aaba3

Contents?: true

Size: 711 Bytes

Versions: 7

Compression:

Stored size: 711 Bytes

Contents

# frozen_string_literal: true

module BusinessFlow
  # Fire ActiveSupport events for every step that's run and on errors
  class InstrumentedExecutor < DefaultStepExecutor
    def call
      name = flow_event_name
      payload = { flow: flow }
      ActiveSupport::Notifications.instrument(name, payload) do
        super
      end
      notify_errors(name, payload)
    end

    protected

    def notify_errors(name, payload)
      return unless flow.errors?
      ActiveSupport::Notifications.publish(name + '.error', payload)
    end

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

    def flow_event_name
      @flow_event_name ||= flow.class.event_name
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
business_flow-0.19.4 lib/business_flow/instrumented_executor.rb
business_flow-0.19.3 lib/business_flow/instrumented_executor.rb
business_flow-0.19.2 lib/business_flow/instrumented_executor.rb
business_flow-0.19.1 lib/business_flow/instrumented_executor.rb
business_flow-0.19.0 lib/business_flow/instrumented_executor.rb
business_flow-0.18.1 lib/business_flow/instrumented_executor.rb
business_flow-0.18.0 lib/business_flow/instrumented_executor.rb