2010-12-25 08:59:37 -05:00
|
|
|
class Pry
|
|
|
|
module ObjectExtensions
|
2010-12-30 10:01:11 -05:00
|
|
|
|
|
|
|
# Start a Pry REPL.
|
|
|
|
# This method differs from `Pry.start` in that it does not
|
|
|
|
# support an options hash. Also, when no parameter is provided, the Pry
|
|
|
|
# session will start on the implied receiver rather than on
|
|
|
|
# top-level (as in the case of `Pry.start`).
|
|
|
|
# It has two forms of invocation. In the first form no parameter
|
|
|
|
# should be provided and it will start a pry session on the
|
|
|
|
# receiver. In the second form it should be invoked without an
|
|
|
|
# explicit receiver and one parameter; this will start a Pry
|
|
|
|
# session on the parameter.
|
|
|
|
# @param [Object, Binding] target The receiver of the Pry session.
|
|
|
|
# @example First form
|
|
|
|
# "dummy".pry
|
|
|
|
# @example Second form
|
|
|
|
# pry "dummy"
|
|
|
|
# @example Start a Pry session on current self (whatever that is)
|
|
|
|
# pry
|
2010-12-25 09:25:35 -05:00
|
|
|
def pry(target=self)
|
|
|
|
Pry.start(target)
|
2010-12-25 08:59:37 -05:00
|
|
|
end
|
|
|
|
|
2010-12-30 10:01:11 -05:00
|
|
|
# Return a binding object for the receiver.
|
2010-12-25 08:59:37 -05:00
|
|
|
def __binding__
|
|
|
|
if is_a?(Module)
|
|
|
|
return class_eval "binding"
|
|
|
|
end
|
|
|
|
|
|
|
|
unless respond_to? :__binding_impl__
|
2011-01-23 09:03:39 -05:00
|
|
|
begin
|
|
|
|
instance_eval %{
|
|
|
|
def __binding_impl__
|
|
|
|
binding
|
|
|
|
end
|
|
|
|
}
|
|
|
|
rescue TypeError
|
|
|
|
self.class.class_eval %{
|
|
|
|
def __binding_impl__
|
|
|
|
binding
|
|
|
|
end
|
|
|
|
}
|
2010-12-25 08:59:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
__binding_impl__
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# bring the extensions into Object
|
|
|
|
class Object
|
|
|
|
include Pry::ObjectExtensions
|
|
|
|
end
|