Module: Pry::Helpers::OptionsHelpers

Included in:
CommandHelpers
Defined in:
lib/pry/helpers/options_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.method_objectObject

Get the method object parsed by the slop instance


23
24
25
26
27
28
29
30
31
# File 'lib/pry/helpers/options_helpers.rb', line 23

def method_object
  @method_object ||= get_method_or_raise(
    args.empty? ? nil : args.join(" "),
    @method_target,
    super: opts[:super],
    instance: opts.present?(:'instance-methods') && !opts.present?(:methods),
    methods: opts.present?(:methods) && !opts.present?(:'instance-methods')
  )
end

.method_options(opt) ⇒ Object

Add method options to the Pry::Slop instance


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pry/helpers/options_helpers.rb', line 9

def method_options(opt)
  @method_target = target
  opt.on :M, "instance-methods", "Operate on instance methods."
  opt.on :m, :methods, "Operate on methods."
  opt.on :s, :super, "Select the 'super' method. Can be repeated to " \
                     "traverse the ancestors.", as: :count
  opt.on(
    :c, :context, "Select object context to run under.", argument: true
  ) do |context|
    @method_target = Pry.binding_for(target.eval(context))
  end
end

Instance Method Details

#method_objectObject (private)

Get the method object parsed by the slop instance


23
24
25
26
27
28
29
30
31
# File 'lib/pry/helpers/options_helpers.rb', line 23

def method_object
  @method_object ||= get_method_or_raise(
    args.empty? ? nil : args.join(" "),
    @method_target,
    super: opts[:super],
    instance: opts.present?(:'instance-methods') && !opts.present?(:methods),
    methods: opts.present?(:methods) && !opts.present?(:'instance-methods')
  )
end

#method_options(opt) ⇒ Object (private)

Add method options to the Pry::Slop instance


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pry/helpers/options_helpers.rb', line 9

def method_options(opt)
  @method_target = target
  opt.on :M, "instance-methods", "Operate on instance methods."
  opt.on :m, :methods, "Operate on methods."
  opt.on :s, :super, "Select the 'super' method. Can be repeated to " \
                     "traverse the ancestors.", as: :count
  opt.on(
    :c, :context, "Select object context to run under.", argument: true
  ) do |context|
    @method_target = Pry.binding_for(target.eval(context))
  end
end