Module: Hollywood
- Defined in:
- lib/hollywood.rb,
lib/hollywood/version.rb
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Method Summary collapse
Instance Method Details
#callback(*args) ⇒ Object
10 11 12 13 |
# File 'lib/hollywood.rb', line 10 def callback(*args) get_callbacks(args.shift.to_sym).each { |callback| callback.call *(args.take callback.arity) } self end |
#when(event, &block) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/hollywood.rb', line 2 def when(event, &block) event = { event => block } unless event.is_a? Hash new_callbacks = event.map { |event, callback| { :event => event, :callback => callback } } new_callbacks.each { |s| get_callbacks(s[:event]) << s[:callback] } self end |