Module: Hecks::Bluebook::Behaviour::ProcessManager

Included in:
ProcessManager
Defined in:
lib/hecks/bluebook/behaviour/process_manager.rb

Overview

WHAT A PROCESS MANAGER DOES. Its declared half is the trigger, the states and the handlers; the compensation half — saga — is DERIVED from the handler that answers a refusal, not declared.

Instance Method Summary collapse

Instance Method Details

#correlation_headObject



19
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 19

def correlation_head = @correlates_by.to_s.split(".").first.to_sym

#declares_state?(state) ⇒ Boolean

WHETHER A STATE IS ONE THIS PROCEDURE DECLARES — asked of a value a real run left a saga instance holding (its live or rehydrated state), the way Lifecycle#states is asked of an aggregate's resting field. A rehydrated instance in a state no handler could have reached is corruption the durable round-trip introduced.

Returns:

  • (Boolean)


17
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 17

def declares_state?(state) = @states.map(&:to_s).include?(state.to_s)

#handler_for(event) ⇒ Object



10
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 10

def handler_for(event) = @handlers.find { |h| h.event_type == event.to_s }

#hecks_nameObject



8
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 8

def hecks_name = @name

#sagaObject

The compensation half of a procedure, read off the handler that answers REFUSED.

nil for a procedure with no answer to a refusal, which is a legitimate thing to be — a hiring pipeline cannot un-interview anybody.



26
27
28
29
30
31
32
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 26

def saga
  leg = handler_for(Bluebook::ProcessManager::REFUSED)
  return nil unless leg

  Bluebook::Saga.new(trigger: Bluebook::ProcessManager::REFUSED, from_state: leg.from_state,
                     to_state: leg.to_state, reversals: leg.dispatches)
end

#saga?Boolean

Returns:

  • (Boolean)


34
# File 'lib/hecks/bluebook/behaviour/process_manager.rb', line 34

def saga? = !saga.nil?