Class: StandardLedger::Projector::HandlerDsl
- Inherits:
-
Object
- Object
- StandardLedger::Projector::HandlerDsl
- 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
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
-
#initialize ⇒ HandlerDsl
constructor
A new instance of HandlerDsl.
- #on(kind, &block) ⇒ Object
Constructor Details
#initialize ⇒ HandlerDsl
Returns a new instance of HandlerDsl.
472 473 474 |
# File 'lib/standard_ledger/projector.rb', line 472 def initialize @handlers = {} end |
Instance Attribute Details
#handlers ⇒ Object (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
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 |