Module: NoBrainer::QueryRunner

Extended by:
Autoload
Defined in:
lib/no_brainer/query_runner.rb

Defined Under Namespace

Classes: ConnectionLock, DatabaseOnDemand, Driver, EMDriver, Middleware, MissingIndex, Profiler, Reconnect, RunOptions, TableOnDemand, WriteError

Class Method Summary collapse

Methods included from Autoload

autoload, autoload_and_include, eager_autoload, eager_load!, extended

Class Method Details

.em_stackObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/no_brainer/query_runner.rb', line 45

def em_stack
  @em_stack ||= ::Middleware::Builder.new do
    use RunOptions
    use MissingIndex
    use DatabaseOnDemand
    use TableOnDemand
    use Profiler
    use WriteError
    use Reconnect
    use EMDriver
  end
end

.normal_stackObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/no_brainer/query_runner.rb', line 31

def normal_stack
  @normal_stack ||= ::Middleware::Builder.new do
    use RunOptions
    use MissingIndex
    use DatabaseOnDemand
    use TableOnDemand
    use Profiler
    use WriteError
    use ConnectionLock
    use Reconnect
    use Driver
  end
end

.run(*args, &block) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
# File 'lib/no_brainer/query_runner.rb', line 17

def run(*args, &block)
  options = args.extract_options!
  raise ArgumentError unless args.size == 1 || block
  query = args.first || block.call(RethinkDB::RQL.new)
  stack.call(:query => query, :options => options)
end

.stackObject



24
25
26
27
28
29
# File 'lib/no_brainer/query_runner.rb', line 24

def stack
  case NoBrainer::Config.driver
  when :regular then normal_stack
  when :em      then em_stack
  end
end