19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/no_brainer/query_runner/run_options.rb', line 19
def self.run_with(options={}, &block)
options = options.symbolize_keys
if options[:database]
STDERR.puts "[NoBrainer] `run_with(database: ...)' is deprecated, please use `run_with(db: ...)' instead"
options[:db] = options.delete(:database)
end
old_options = Thread.current[:nobrainer_run_with]
Thread.current[:nobrainer_run_with] = (old_options || {}).merge(options)
block.call
ensure
Thread.current[:nobrainer_run_with] = old_options
end
|