Module: BlackStack::Debugging

Defined in:
lib/functions.rb

Overview


PRY Supporting Functions


Constant Summary collapse

@@allow_breakpoints =
false

Class Method Summary collapse

Class Method Details

.allow_breakpointsObject

return true if breakpoints are allowed



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

def self.allow_breakpoints
  @@allow_breakpoints
end

.breakpointObject

BlackStack::Debugging.breakpoint can be invoked in the middle of a running program. It opens a Pry session at the point it’s called and makes all program state at that point available. When the session ends the program continues with any modifications you made to it.

BlackStack::Debugging.breakpoint is just calling the Pry’s ‘binding.pry` method, but only if the @@allow_breakpoints is true.



26
27
28
29
# File 'lib/functions.rb', line 26

def self.breakpoint()
  # start a REPL session, if breakpoints are allowed

  binding.pry if @@allow_breakpoints
end

.set(h) ⇒ Object

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



16
17
18
# File 'lib/functions.rb', line 16

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