Class: Typed::Events
- Inherits:
-
Object
- Object
- Typed::Events
- Defined in:
- lib/typed/events.rb
Instance Method Summary collapse
- #fire(type, key, val) ⇒ Object
-
#initialize ⇒ Events
constructor
A new instance of Events.
- #on(type, &block) ⇒ Object
Constructor Details
#initialize ⇒ Events
Returns a new instance of Events.
3 4 5 |
# File 'lib/typed/events.rb', line 3 def initialize @callbacks = {} end |
Instance Method Details
#fire(type, key, val) ⇒ Object
11 12 13 |
# File 'lib/typed/events.rb', line 11 def fire(type, key, val) event(type).each{|block| block.call(key,val)} end |
#on(type, &block) ⇒ Object
7 8 9 |
# File 'lib/typed/events.rb', line 7 def on(type, &block) event(type) << block end |