Class: MockWebService::Async

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mock-web-service/async.rb

Instance Method Summary collapse

Constructor Details

#initializeAsync

Returns a new instance of Async.



5
6
7
8
# File 'lib/mock-web-service/async.rb', line 5

def initialize
  @queue = Queue.new
  Thread.new { loop { @queue.pop.call } }
end

Instance Method Details

#run(&blk) ⇒ Object



10
11
12
# File 'lib/mock-web-service/async.rb', line 10

def run(&blk)
  @queue.push blk
end