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



360
361
362
# File 'lib/functions.rb', line 360

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



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/functions.rb', line 365

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