Class: Hecks::Bluebook::DSL::ProcessManagerBuilder::HandlerBuilder

Inherits:
Object
  • Object
show all
Includes:
WordGate
Defined in:
lib/hecks/bluebook/dsl/process_manager_builder.rb

Constant Summary collapse

GRAMMAR_CONTEXT =
"Handler"

Constants included from WordGate

WordGate::NOT_ADMITTED

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHandlerBuilder

Returns a new instance of HandlerBuilder.



178
# File 'lib/hecks/bluebook/dsl/process_manager_builder.rb', line 178

def initialize = @dispatches = []

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hecks::Bluebook::DSL::WordGate

Instance Attribute Details

#dispatchesObject (readonly)

Returns the value of attribute dispatches.



174
175
176
# File 'lib/hecks/bluebook/dsl/process_manager_builder.rb', line 174

def dispatches
  @dispatches
end

Instance Method Details

#dispatch_impl(command_ref, with: nil) ⇒ Object

THE COMMAND ITSELF (ADR 0025, "events and reactions" — command references become first-class), same shape and same reasons as PolicyBuilder#trigger's own header — bare constant live, quoted text only under shadow-parsing (S0a's bridge; frozen era text still writes dispatch "Banking::Account.Debit").

RENAMED FROM dispatch — item #13's full metaprogrammed dispatch (slice 4), same reasoning as trigger_impl above.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/hecks/bluebook/dsl/process_manager_builder.rb', line 188

def dispatch_impl(command_ref, with: nil)
  if command_ref.is_a?(::String) && !MetaValidator.shadow_parsing?
    raise InvalidProcessManager,
          "dispatch #{command_ref.inspect} is quoted text — give the bare command constant " \
          "instead, e.g. dispatch Account::Debit"
  end

  DispatchSpec.new(
    command_name: Naming.command_ref(command_ref),
    with_spec:    (with || {}).to_a
  ).tap do |dispatch|
    dispatch.instance_variable_set(:@projection_declared, !with.nil?)
    @dispatches << dispatch
  end
end