lib/pry/commands/ls/methods*: move #below_ceiling

Since it's used only in one place, it shouldn't be in the module. Also,
add the missing switch.
This commit is contained in:
Kyrylo Silin 2013-12-01 02:59:21 +02:00
parent f9a99d8fe8
commit 5a68874a6c
2 changed files with 16 additions and 14 deletions

View File

@ -18,6 +18,7 @@ class Pry
@ppp_switch = opts[:ppp]
@jruby_switch = opts['all-java']
@quiet_switch = opts[:quiet]
@verbose_switch = opts[:verbose]
end
def correct_opts?
@ -35,6 +36,21 @@ class Pry
end.join('')
end
# Get a lambda that can be used with `take_while` to prevent over-eager
# traversal of the Object's ancestry graph.
def below_ceiling
ceiling = if @quiet_switch
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
Pry.config.ls.ceiling
elsif @verbose_switch
[]
else
Pry.config.ls.ceiling.dup
end
lambda { |klass| !ceiling.include?(klass) }
end
end
end
end

View File

@ -23,20 +23,6 @@ module Pry::Command::Ls::MethodsHelper
end
end
# Get a lambda that can be used with `take_while` to prevent over-eager
# traversal of the Object's ancestry graph.
def below_ceiling
ceiling = if @quiet_switch
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
Pry.config.ls.ceiling
elsif @verbose_switch
[]
else
Pry.config.ls.ceiling.dup
end
lambda { |klass| !ceiling.include?(klass) }
end
def format(methods)
methods.sort_by(&:name).map do |method|
if method.name == 'method_missing'