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::Core::Workflow.descendants, *Sequent::Core::Projector.descendants].each do |handler_class|
    next unless handler_class.handles_message?(event)

    if handler_class < Sequent::Workflow
      @result.invoked_workflow(EventInvokedHandler.new(event, handler_class))
    elsif handler_class < 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