Module: BlackStack::Debugging

Defined in:
lib/functions.rb

Overview


PRY Supporting Functions


Constant Summary collapse

@@allow_breakpoints =
false
@@verbose =
false

Class Method Summary collapse

Class Method Details

.allow_breakpointsObject

return true if breakpoints are allowed



12
13
14
# File 'lib/functions.rb', line 12

def self.allow_breakpoints
  @@allow_breakpoints
end

.set(h) ⇒ Object

set breakpoints allowed if the hash contains a key :allow_breakpoints with a value of true



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/functions.rb', line 17

def self.set(h)
  @@allow_breakpoints = h[:allow_breakpoints] if h[:allow_breakpoints].is_a?(TrueClass)
  @@verbose = h[:verbose] if h[:verbose].is_a?(TrueClass)

  if !@@allow_breakpoints
    # monkey patching the pry method to not break on breakpoints
    new_pry = lambda do
      print "Breakpoint are not allowed" if @@verbose
    end

    Binding.class_eval do 
      alias_method :old_pry, :pry
      define_method :pry, new_pry
    end
  end
end