Class: NoBrainer::QueryRunner::DatabaseOnDemand
- Inherits:
-
Middleware
- Object
- Middleware
- NoBrainer::QueryRunner::DatabaseOnDemand
show all
- Defined in:
- lib/no_brainer/query_runner/database_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
12
13
|
# File 'lib/no_brainer/query_runner/database_on_demand.rb', line 2
def call(env)
@runner.call(env)
rescue RuntimeError => e
if db_name = handle_database_on_demand_exception?(env, e)
return {} if NoBrainer::RQL.db_drop?(env[:query])
auto_create_database(env, db_name)
retry
end
raise
end
|
#handle_database_on_demand_exception?(env, e) ⇒ Boolean
15
16
17
|
# File 'lib/no_brainer/query_runner/database_on_demand.rb', line 15
def handle_database_on_demand_exception?(env, e)
/^Database `(.+)` does not exist\.$/.match(e.message).try(:[], 1)
end
|