Class: CallbackQueue
Instance Method Summary collapse
- #enqueue(proc = nil, &block) ⇒ Object
-
#initialize ⇒ CallbackQueue
constructor
A new instance of CallbackQueue.
- #notify_all ⇒ Object
Constructor Details
#initialize ⇒ CallbackQueue
2 3 4 |
# File 'lib/hyalite/callback_queue.rb', line 2 def initialize @queue = [] end |
Instance Method Details
#enqueue(proc = nil, &block) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/hyalite/callback_queue.rb', line 6 def enqueue(proc = nil, &block) if proc @queue << proc elsif block_given? @queue << block end end |
#notify_all ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/hyalite/callback_queue.rb', line 14 def notify_all queue = @queue @queue = [] while queue.length > 0 proc = queue.shift proc.call end end |