Class: NoBrainer::QueryRunner::EMDriver
- Inherits:
-
Middleware
- Object
- Middleware
- NoBrainer::QueryRunner::EMDriver
- Defined in:
- lib/no_brainer/query_runner/em_driver.rb
Defined Under Namespace
Classes: ResponseHandler
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Middleware
Constructor Details
This class inherits a constructor from NoBrainer::QueryRunner::Middleware
Class Method Details
.sync(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/no_brainer/query_runner/em_driver.rb', line 15 def self.sync(&block) # Similar to em-synchrony's sync. f = Fiber.current block.call(proc do |val| if f == Fiber.current return val else f.resume(val) end end) Fiber.yield end |
Instance Method Details
#call(env) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/no_brainer/query_runner/em_driver.rb', line 5 def call(env) = env[:options] = .merge(:db => RethinkDB::RQL.new.db([:db])) if [:db] handler = ResponseHandler.new query_handler = env[:query].em_run(NoBrainer.connection.raw, handler, ) handler.on_dispatch(query_handler) handler.value end |