Module: Groovestack::Base::Listener::ClassMethods
- Defined in:
- lib/groovestack/base/listeners.rb
Instance Method Summary collapse
Instance Method Details
#init(_throttle_seconds: 0) ⇒ Object
11 12 13 |
# File 'lib/groovestack/base/listeners.rb', line 11 def init(_throttle_seconds: 0) raise 'listener must define class method init' end |
#throttle(seconds) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/groovestack/base/listeners.rb', line 15 def throttle(seconds) wait = false proc do |&block| unless wait wait = true Thread.new do block.call sleep(seconds) wait = false end end end end |