Class: Rethinker::QueryRunner::TableOnDemand

Inherits:
Middleware
  • Object
show all
Defined in:
lib/rethinker/query_runner/table_on_demand.rb

Instance Method Summary collapse

Methods inherited from Middleware

#initialize

Constructor Details

This class inherits a constructor from Rethinker::QueryRunner::Middleware

Instance Method Details

#call(env) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/rethinker/query_runner/table_on_demand.rb', line 2

def call(env)
  @runner.call(env)
rescue RuntimeError => e
  if e.message =~ /^Table `(.+)` does not exist\.$/
    # TODO Lookup the Model, and get the primary key name
    Rethinker.table_create $1
    retry
  end
  raise e
end