5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/safeconsole/pry_config.rb', line 5
def self.add_hooks
Pry.hooks.add_hook(:after_read, "safeconsole__transaction_watcher") do |output, binding, pry|
if defined?(ActiveRecord) && binding.last_exception.is_a?(ActiveRecord::StatementInvalid)
puts Messages.invalid_query
end
end
Pry.hooks.add_hook(:after_eval, "safeconsole__exit") do |output, binding, _pry|
if Object.const_defined?(:Safeconsole) && (binding.config.prompt_name == "safeconsole")
SessionWatcher.command_ran
binding.eval("exit") if Console.done?
if output == "safeconsole#refresh"
SessionWatcher.transaction_commands = 0
binding.eval("exit")
end
end
end
end
|