Class: StandardLedger::Projector::HandlerDsl

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_ledger/projector.rb

Overview

Internal collector for the block-DSL form. Captures ‘on(:kind)` calls into a hash keyed by kind. Wildcard `on(:_)` is reserved as a catch-all — its handler runs only when no specific-kind handler matched.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHandlerDsl

Returns a new instance of HandlerDsl.



472
473
474
# File 'lib/standard_ledger/projector.rb', line 472

def initialize
  @handlers = {}
end

Instance Attribute Details

#handlersObject (readonly)

Returns the value of attribute handlers.



470
471
472
# File 'lib/standard_ledger/projector.rb', line 470

def handlers
  @handlers
end

Instance Method Details

#on(kind, &block) ⇒ Object

Raises:

  • (ArgumentError)


476
477
478
479
# File 'lib/standard_ledger/projector.rb', line 476

def on(kind, &block)
  raise ArgumentError, "on(:#{kind}) requires a block" unless block
  @handlers[kind.to_sym] = block
end