Class: Rooibos::Router::Flow::Inward

Inherits:
Object
  • Object
show all
Includes:
Dispatch
Defined in:
lib/rooibos/router/flow/inward.rb

Overview

Inward flow: messages traveling toward the leaves.

Observe → receive → forward → otherwise.

Instance Method Summary collapse

Constructor Details

#initialize(observes:, receives:, forwards:, otherwises:, routes:) ⇒ Inward

Returns a new instance of Inward.



19
20
21
22
# File 'lib/rooibos/router/flow/inward.rb', line 19

def initialize(observes:, receives:, forwards:, otherwises:, routes:)
  super
  validate_routes!
end

Instance Method Details

#call(message, model) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/rooibos/router/flow/inward.rb', line 24

def call(message, model)
  transition = run_all(observes, message, model)
  config = Configuration.new(message:, model: transition.model)
  apply_first_matching(receives, config, transition) ||
    apply_first_matching(forwards, config, transition) ||
    apply_first_matching(otherwises, config, transition) ||
    transition
end