Class: MockWebService::Async
- Inherits:
-
Object
- Object
- MockWebService::Async
- Includes:
- Singleton
- Defined in:
- lib/mock-web-service/async.rb
Instance Method Summary collapse
-
#initialize ⇒ Async
constructor
A new instance of Async.
- #run(&blk) ⇒ Object
Constructor Details
#initialize ⇒ Async
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 |