2011-10-15 03:03:41 -04:00
|
|
|
class Pry
|
|
|
|
module Helpers
|
|
|
|
module OptionsHelpers
|
|
|
|
module_function
|
|
|
|
|
2011-12-31 10:57:50 -05:00
|
|
|
# Add method options to the Slop instance
|
|
|
|
def method_options(opt)
|
2011-10-15 03:03:41 -04:00
|
|
|
@method_target = target
|
|
|
|
opt.on :M, "instance-methods", "Operate on instance methods."
|
|
|
|
opt.on :m, :methods, "Operate on methods."
|
2011-12-31 10:57:50 -05:00
|
|
|
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors.", :as => :count
|
2012-05-27 04:36:41 -04:00
|
|
|
opt.on :c, :context, "Select object context to run under.", :argument => true do |context|
|
2011-10-15 03:03:41 -04:00
|
|
|
@method_target = Pry.binding_for(target.eval(context))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-12-31 10:57:50 -05:00
|
|
|
# Get the method object parsed by the slop instance
|
|
|
|
def method_object
|
|
|
|
@method_object ||= get_method_or_raise(args.empty? ? nil : args.join(" "), @method_target,
|
2011-12-08 01:26:04 -05:00
|
|
|
:super => opts[:super],
|
|
|
|
:instance => opts.present?(:'instance-methods') && !opts.present?(:'methods'),
|
|
|
|
:methods => opts.present?(:'methods') && !opts.present?(:'instance-methods')
|
|
|
|
)
|
2011-10-15 03:03:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|