summaryrefslogtreecommitdiff
path: root/lib/pry/commands/ls/interrogatable.rb
blob: 399d11f36fbbaaf69ccc8b69314a564d56e0aac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Pry
  class Command
    class Ls < Pry::ClassCommand
      module Interrogatable
        private

        def interrogating_a_module?
          Module === @interrogatee
        end

        def interrogatee_mod
          if interrogating_a_module?
            @interrogatee
          else
            singleton = Pry::Method.singleton_class_of(@interrogatee)
            singleton.ancestors.grep(::Class).reject { |c| c == singleton }.first
          end
        end
      end
    end
  end
end