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.



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

def initialize(result)
  @result = result
end

Instance Attribute Details

#projectorsObject (readonly)

Returns the value of attribute projectors.



59
60
61
# File 'lib/sequent/util/dry_run.rb', line 59

def projectors
  @projectors
end

#workflowsObject (readonly)

Returns the value of attribute workflows.



59
60
61
# File 'lib/sequent/util/dry_run.rb', line 59

def workflows
  @workflows
end

Instance Method Details

#process_event(event) ⇒ Object



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

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
    raise PublishEventError.new(handler.class, event)
  end
end