summaryrefslogtreecommitdiff
path: root/lib/pry/commands/ls/interrogatable.rb
blob: 5904d1b487d95f6bf95e9ee93576dbd35a130c96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Pry::Command::Ls::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