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.
583 584 585 |
# File 'lib/standard_ledger/projector.rb', line 583 def initialize @handlers = {} end |
Instance Attribute Details
#handlers ⇒ Object (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
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 |