Class: NoBrainer::QueryRunner::TableOnDemand
- Inherits:
-
Middleware
- Object
- Middleware
- NoBrainer::QueryRunner::TableOnDemand
show all
- Defined in:
- lib/no_brainer/query_runner/table_on_demand.rb
Instance Method Summary
collapse
Methods inherited from Middleware
#initialize
Instance Method Details
#call(env) ⇒ Object
2
3
4
5
6
7
8
9
10
11
|
# File 'lib/no_brainer/query_runner/table_on_demand.rb', line 2
def call(env)
@runner.call(env)
rescue RuntimeError => e
if table_info = handle_table_on_demand_exception?(env, e)
auto_create_table(env, *table_info)
retry
end
raise
end
|
#handle_table_on_demand_exception?(env, e) ⇒ Boolean
13
14
15
|
# File 'lib/no_brainer/query_runner/table_on_demand.rb', line 13
def handle_table_on_demand_exception?(env, e)
/^Table `(.+)\.(.+)` does not exist\.$/.match(e.message).try(:[], 1..2)
end
|