Class: Hecks::Runtime::EntityInterpreter
- Inherits:
-
Object
- Object
- Hecks::Runtime::EntityInterpreter
- Includes:
- Interpreting
- Defined in:
- lib/hecks/runtime/entity_interpreter.rb
Defined Under Namespace
Classes: Context
Constant Summary collapse
- DISPATCH_ORDER =
THE DECLARED ORDER, HAND-TYPED — mirrors Vocabulary::EntityDispatchOrder (language/bluebook/vocabulary.bluebook:217-232), held equal to it by spec/vocabulary_conformance_spec.rb the same way CommandInterpreter's own DISPATCH_ORDER is; see that constant's doc comment for why this is hand-typed rather than read live off the meta-domain at every dispatch. Shorter than the aggregate order for the same reasons the declaration itself gives : no refuse_unknown_arguments/refuse_absent_arguments (an entity inherits its aggregate's own gate) and no assign_creation_attributes (an entity is never created through this path).
Hecks::Vocabulary.symbols("EntityDispatchOrder")
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#call(domain, aggregate, dotted, legacy_args, route: nil, with: nil, dry_run: false) ⇒ Object
dry_run:— CommandInterpreter#call's own twin, see that method's comment for the shared reasoning (Dispatcher#dry_run?'s own entry point). -
#initialize(registry, rules:) ⇒ EntityInterpreter
constructor
A new instance of EntityInterpreter.
Methods included from Interpreting
Constructor Details
#initialize(registry, rules:) ⇒ EntityInterpreter
Returns a new instance of EntityInterpreter.
50 51 52 53 |
# File 'lib/hecks/runtime/entity_interpreter.rb', line 50 def initialize(registry, rules:) @registry = registry @rules = rules end |
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
19 20 21 |
# File 'lib/hecks/runtime/entity_interpreter.rb', line 19 def registry @registry end |
Instance Method Details
#call(domain, aggregate, dotted, legacy_args, route: nil, with: nil, dry_run: false) ⇒ Object
dry_run: — CommandInterpreter#call's own twin, see that method's
comment for the shared reasoning (Dispatcher#dry_run?'s own entry
point). step_save/step_emit are the only two steps here that
read it either.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/hecks/runtime/entity_interpreter.rb', line 59 def call(domain, aggregate, dotted, legacy_args, route: nil, with: nil, dry_run: false) *entity_names, command_name = dotted.to_s.split(".") if entity_names.empty? raise UnknownVerb, RefusalWording.render("UnknownVerb", "entity_unknown", aggregate: aggregate.hecks_name, entity: dotted.to_s.inspect) end chain = walk_entity_chain(aggregate, entity_names) entity = chain.last command = entity.command(command_name) || raise(UnknownVerb, RefusalWording.render("UnknownVerb", "entity_no_command", entity: entity.hecks_name, command: command_name.inspect)) args = Routing.payload(command, with: with, legacy: legacy_args) ctx = Context.new(domain, aggregate, entity, entity_names.join("."), command, command_name, args) ctx.chain = chain ctx.route = route ctx.dry_run = dry_run ctx.plan = DependencyPlanning::Analyzer.call(aggregate: entity, command: command) run_dispatch_order(DISPATCH_ORDER, ctx) [ctx.instance, ctx.result, ctx.plan, ctx.persistence_outcome] end |