Class: Bricolage::EventHandlers
- Inherits:
-
Object
- Object
- Bricolage::EventHandlers
- Defined in:
- lib/bricolage/eventhandlers.rb
Instance Method Summary collapse
- #add(handler) ⇒ Object
-
#initialize ⇒ EventHandlers
constructor
A new instance of EventHandlers.
- #run(event) ⇒ Object
Constructor Details
#initialize ⇒ EventHandlers
Returns a new instance of EventHandlers.
3 4 5 |
# File 'lib/bricolage/eventhandlers.rb', line 3 def initialize @handlers = [] end |
Instance Method Details
#add(handler) ⇒ Object
7 8 9 |
# File 'lib/bricolage/eventhandlers.rb', line 7 def add(handler) @handlers.push handler end |
#run(event) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bricolage/eventhandlers.rb', line 11 def run(event) @handlers.each do |h| begin h.call(event) rescue => err $stderr.puts "hook error: #{err.class}: #{err.}" err.backtrace.each do |line| $stderr.puts "\t#{line}" end end end end |