Class: Object

Inherits:
BasicObject
Defined in:
lib/pry/core_extensions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) __binding__

Return a binding object for the receiver.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pry/core_extensions.rb', line 30

def __binding__
  if is_a?(Module)
    return class_eval "binding"
  end

  unless respond_to? :__binding_impl__
    begin
      instance_eval %{
        def __binding_impl__
          binding
        end
      }
    rescue TypeError
      self.class.class_eval %{
        def __binding_impl__
          binding
        end
      }
    end
  end

  __binding_impl__
end

- (Object) pry(*args)

Examples:

First

"dummy".pry

Second

binding.pry

An example with options

def my_method
  binding.pry :quiet => true
end
my_method()

Parameters:

  • the (Binding)

    binding or options hash if no binding needed.

  • the (Hash)

    options hash.



21
22
23
24
25
26
27
# File 'lib/pry/core_extensions.rb', line 21

def pry(*args)
  if args.first.is_a?(Hash) || args.length == 0
    args.unshift(self)
  end
  
  Pry.start(*args)
end