Class: NoBrainer::QueryRunner::EMDriver::ResponseHandler::Cursor
- Inherits:
-
Object
- Object
- NoBrainer::QueryRunner::EMDriver::ResponseHandler::Cursor
- Includes:
- Enumerable
- Defined in:
- lib/no_brainer/query_runner/em_driver.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(handler, queue) ⇒ Cursor
constructor
A new instance of Cursor.
Constructor Details
#initialize(handler, queue) ⇒ Cursor
Returns a new instance of Cursor.
103 104 105 106 |
# File 'lib/no_brainer/query_runner/em_driver.rb', line 103 def initialize(handler, queue) @handler = handler @queue = queue end |
Instance Method Details
#close ⇒ Object
108 109 110 |
# File 'lib/no_brainer/query_runner/em_driver.rb', line 108 def close @handler.close_query_handle end |
#each(&block) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/no_brainer/query_runner/em_driver.rb', line 112 def each(&block) return enum_for(:each) unless block raise "Can only iterate over a cursor once." if @iterated @iterated = true loop do case result = NoBrainer::QueryRunner::EMDriver.sync { |w| @queue.pop(&w) } when :close then return self when Exception then raise result else result.each { |v| block.call(v) } end end end |