Module: MINT::InteractorHelpers
- Included in:
- Interactor
- Defined in:
- lib/MINT-core/model/interactor_helpers.rb
Instance Method Summary collapse
- #restart_timeout(seconds, event, cb = nil) ⇒ Object
- #start_timeout(seconds, event, cb = nil) ⇒ Object
- #stop_timeout ⇒ Object
Instance Method Details
#restart_timeout(seconds, event, cb = nil) ⇒ Object
20 21 22 23 |
# File 'lib/MINT-core/model/interactor_helpers.rb', line 20 def restart_timeout(seconds,event,cb = nil) stop_timeout start_timeout(seconds,event,cb) end |
#start_timeout(seconds, event, cb = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/MINT-core/model/interactor_helpers.rb', line 3 def start_timeout(seconds,event,cb = nil) if not @timer @timer = EventMachine::Timer.new(seconds) do cb.call if cb process_event event end else puts "timer already started!!!" end end |
#stop_timeout ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/MINT-core/model/interactor_helpers.rb', line 13 def stop_timeout if @timer # p "stopped timer" @timer.cancel @timer = nil end end |