Sha256: a10406ecd997fa5a98a7381255750aec87a2545d28ade4c319f0ba70b041a259

Contents?: true

Size: 680 Bytes

Versions: 16

Compression:

Stored size: 680 Bytes

Contents

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

16 entries across 16 versions & 1 rubygems

Version Path
business_flow-0.17.5 lib/business_flow/instrumented_executor.rb
business_flow-0.17.4 lib/business_flow/instrumented_executor.rb
business_flow-0.17.3 lib/business_flow/instrumented_executor.rb
business_flow-0.17.2 lib/business_flow/instrumented_executor.rb
business_flow-0.17.1 lib/business_flow/instrumented_executor.rb
business_flow-0.17.0 lib/business_flow/instrumented_executor.rb
business_flow-0.16.0 lib/business_flow/instrumented_executor.rb
business_flow-0.15.1 lib/business_flow/instrumented_executor.rb
business_flow-0.15.0 lib/business_flow/instrumented_executor.rb
business_flow-0.14.3 lib/business_flow/instrumented_executor.rb
business_flow-0.14.2 lib/business_flow/instrumented_executor.rb
business_flow-0.14.1 lib/business_flow/instrumented_executor.rb
business_flow-0.14.0 lib/business_flow/instrumented_executor.rb
business_flow-0.13.0 lib/business_flow/instrumented_executor.rb
business_flow-0.12.1 lib/business_flow/instrumented_executor.rb
business_flow-0.12.0 lib/business_flow/instrumented_executor.rb