Module: Appetizer::Events
- Included in:
- App
- Defined in:
- lib/appetizer/events.rb
Instance Method Summary collapse
Instance Method Details
#fire(event) ⇒ Object
3 4 5 |
# File 'lib/appetizer/events.rb', line 3 def fire event hooks[event].each { |h| h.call } end |
#hooks ⇒ Object
7 8 9 |
# File 'lib/appetizer/events.rb', line 7 def hooks @hooks ||= Hash.new { |h, k| h[k] = [] } end |
#on(event, &block) ⇒ Object
11 12 13 |
# File 'lib/appetizer/events.rb', line 11 def on event, &block hooks[event] << block end |