Module: Rucola::Debugger

Defined in:
lib/rucola/ruby_debug.rb

Class Method Summary collapse

Class Method Details

.use!Object

:nodoc:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rucola/ruby_debug.rb', line 7

def self.use! #:nodoc:
  Kernel.module_eval do
    # If enabled in the Configuration (default in `debug` environment is on), calling #debugger will try to load the ruby-debug gem.
    # In other modes however any call to #debugger will be ignored.
    # However, for performance reasons you still might want to take out any calls in a release build.
    def debugger(steps = 1)
      rucola_load_ruby_debug(steps)
    end
    
    private
    
    def rucola_load_ruby_debug(steps) #:nodoc:
      require 'ruby-debug'
      debugger(steps)
    rescue LoadError
      log.error "The ruby-debug gem is needed to be able to use the debugger, but it wasn't found."
    end
  end
end