Method: CodeEvents#fire
- Defined in:
- lib/source/redshift/code_events.rb
#fire(sym, delay, *args) ⇒ Object
call-seq:
obj.fire(sym) -> obj
obj.fire(sym, delay, arg, ...) -> obj
Instructs obj to call the Proc objects associated with the event sym, then returns obj. Optionally delays the firing of the event by delay milliseconds. The second form allows passing of arguments to the event’s Proc objects, but if any arguments are passed, the first must be the delay argument.
obj.upon(:A) {|x| puts x } #=> obj
obj.upon(:B) {|y| puts y } #=> obj
obj.upon(:C) { puts 'fire 3' } #=> obj
obj.fire(:A, 500, 'fire 1').fire(:B, 0, 'fire 2').fire(:C)
produces:
fire 2
fire 3
fire 1
71 72 73 74 75 76 |
# File 'lib/source/redshift/code_events.rb', line 71 def fire(sym, delay, *args) name = sym.to_sym return self unless @code_events && events_group = @code_events[name] events_group.each {|proc| proc.process_event(self, delay, args) } return self end |