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.



583
584
585
# File 'lib/standard_ledger/projector.rb', line 583

def initialize
  @handlers = {}
end

Instance Attribute Details

#handlersObject (readonly)

Returns the value of attribute handlers.



581
582
583
# File 'lib/standard_ledger/projector.rb', line 581

def handlers
  @handlers
end

Instance Method Details

#on(kind, &block) ⇒ Object

Raises:

  • (ArgumentError)


587
588
589
590
# File 'lib/standard_ledger/projector.rb', line 587

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