class Sequent::Util::DryRun::Result
Contains the result of a dry run.
Constants
- EventCalledHandlers
Attributes
command_with_events[R]
event_invoked_projectors[R]
event_invoked_workflows[R]
Public Class Methods
new()
click to toggle source
# File lib/sequent/util/dry_run.rb, line 94 def initialize @command_with_events = {} @event_invoked_projectors = [] @event_invoked_workflows = [] end
Public Instance Methods
invoked_projector(event_invoked_handler)
click to toggle source
# File lib/sequent/util/dry_run.rb, line 100 def invoked_projector(event_invoked_handler) event_invoked_projectors << event_invoked_handler end
invoked_workflow(event_invoked_handler)
click to toggle source
# File lib/sequent/util/dry_run.rb, line 104 def invoked_workflow(event_invoked_handler) event_invoked_workflows << event_invoked_handler end
print(io)
click to toggle source
Prints the output from tree
to the given ‘io`
# File lib/sequent/util/dry_run.rb, line 145 def print(io) tree.each_with_index do |(command, event_called_handlerss), index| io.puts '+++++++++++++++++++++++++++++++++++' if index == 0 io.puts "Command: #{command.class} resulted in #{event_called_handlerss.length} events" event_called_handlerss.each_with_index do |event_called_handlers, i| io.puts '' if i > 0 io.puts "-- Event #{event_called_handlers.event.class} was handled by:" io.puts "-- Projectors: [#{event_called_handlers.projectors.join(', ')}]" io.puts "-- Workflows: [#{event_called_handlers.workflows.join(', ')}]" end io.puts '+++++++++++++++++++++++++++++++++++' end end
published_command_with_events(command, events)
click to toggle source
# File lib/sequent/util/dry_run.rb, line 108 def published_command_with_events(command, events) command_with_events[command] = events end
tree()
click to toggle source
Returns the command with events as a tree structure.
{
command => [ EventCalledHandlers, EventCalledHandlers, EventCalledHandlers, ]
}
The EventCalledHandlers
contains an Event
with the lists of ‘Sequent::Projector`s and `Sequent::Workflow`s that were called.
# File lib/sequent/util/dry_run.rb, line 127 def tree command_with_events.reduce({}) do |memo, (command, events)| events_to_handlers = events.map do |event| for_current_event = ->(pair) { pair.event == event } EventCalledHandlers.new( event, event_invoked_projectors.select(&for_current_event).map(&:handler), event_invoked_workflows.select(&for_current_event).map(&:handler), ) end memo[command] = events_to_handlers memo end end