Class: Sequent::Util::DryRun::RecordingEventPublisher

Inherits:
Core::EventPublisher show all
Defined in:
lib/sequent/util/dry_run.rb

Overview

Records which Projector’s and Workflow’s are executed

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Core::EventPublisher

#publish_events

Constructor Details

#initialize(result) ⇒ RecordingEventPublisher

Returns a new instance of RecordingEventPublisher.



63
64
65
66
# File 'lib/sequent/util/dry_run.rb', line 63

def initialize(result)
  super()
  @result = result
end

Instance Attribute Details

#projectorsObject (readonly)

Returns the value of attribute projectors.



61
62
63
# File 'lib/sequent/util/dry_run.rb', line 61

def projectors
  @projectors
end

#workflowsObject (readonly)

Returns the value of attribute workflows.



61
62
63
# File 'lib/sequent/util/dry_run.rb', line 61

def workflows
  @workflows
end

Instance Method Details

#process_event(event) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/sequent/util/dry_run.rb', line 68

def process_event(event)
  Sequent.configuration.event_handlers.each do |handler|
    next unless handler.class.handles_message?(event)

    if handler.is_a?(Sequent::Workflow)
      @result.invoked_workflow(EventInvokedHandler.new(event, handler.class))
    elsif handler.is_a?(Sequent::Projector)
      @result.invoked_projector(EventInvokedHandler.new(event, handler.class))
    else
      fail "Unrecognized event_handler #{handler.class} called for event #{event.class}"
    end
  rescue StandardError
    raise PublishEventError.new(handler.class, event)
  end
end