Class: Hecks::Runtime::CommandInterpreter

Inherits:
Object
  • Object
show all
Includes:
ArgumentGate, MutationApplier, Interpreting
Defined in:
lib/hecks/runtime/command_interpreter.rb,
lib/hecks/runtime/command_interpreter/argument_gate.rb,
lib/hecks/runtime/command_interpreter/mutation_applier.rb

Overview

The dispatch pipeline for a command on an aggregate head. The payload gate lives in command_interpreter/argument_gate.rb, the mutation walk in command_interpreter/mutation_applier.rb; what stays here is the order of the steps and how a record is addressed.

Defined Under Namespace

Modules: ArgumentGate, MutationApplier Classes: Context

Constant Summary collapse

DISPATCH_ORDER =

THE DECLARED ORDER, HAND-TYPED — mirrors Vocabulary::AggregateDispatchOrder (language/bluebook/vocabulary.bluebook:188-205), held equal to it by spec/vocabulary_conformance_spec.rb the same way every other vocabulary in that file is (RefusalWording::TEMPLATES, CommandRules::MUTATION_OPS, ...) rather than read live off the meta-domain at every dispatch — Runtime::RefusalWording's own doc comment gives the same reason.

Hecks::Vocabulary.symbols("AggregateDispatchOrder")

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Interpreting

included

Constructor Details

#initialize(registry, rules:) ⇒ CommandInterpreter

Returns a new instance of CommandInterpreter.



42
43
44
45
# File 'lib/hecks/runtime/command_interpreter.rb', line 42

def initialize(registry, rules:)
  @registry = registry
  @rules    = rules
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



24
25
26
# File 'lib/hecks/runtime/command_interpreter.rb', line 24

def registry
  @registry
end

Instance Method Details

#call(domain, aggregate, command, args, correlation = nil, route: nil, dry_run: false) ⇒ Object

dry_run: — Dispatcher#dry_run?'s own entry point. Every step up through enforce_ensures/enforce_invariants runs exactly as a real dispatch would (givens checked, mutations applied to ctx.instance in memory); step_save/step_emit are the only two that read this flag, each skipping its own real work — see their own comments.



52
53
54
55
56
57
58
59
60
# File 'lib/hecks/runtime/command_interpreter.rb', line 52

def call(domain, aggregate, command, args, correlation = nil, route: nil, dry_run: false)
  ctx = Context.new(domain, aggregate, command, args)
  ctx.correlation = correlation
  ctx.route = route
  ctx.dry_run = dry_run
  ctx.plan = DependencyPlanning::Analyzer.call(aggregate: aggregate, command: command)
  run_dispatch_order(DISPATCH_ORDER, ctx)
  [ctx.instance, ctx.result, ctx.plan, ctx.persistence_outcome]
end