class Robe::Sash::IncludesTracker

Public Class Methods

method_owner_and_inst(owner, name_cache) click to toggle source
# File lib/robe/sash/includes_tracker.rb, line 6
def self.method_owner_and_inst(owner, name_cache)
  includers = maybe_scan

  mod, inst = includers[owner].first

  if mod
    [name_cache[mod], inst]
  else
    [nil, true]
  end
end
reset!() click to toggle source
# File lib/robe/sash/includes_tracker.rb, line 18
def self.reset!
  @@hosts = nil
end

Private Class Methods

maybe_scan() click to toggle source
# File lib/robe/sash/includes_tracker.rb, line 24
def self.maybe_scan
  includers = @@hosts

  unless includers
    @@hosts = includers = Hash.new { |h, k| h[k] = [] }

    ObjectSpace.each_object(Module) do |cl|
      next unless cl.respond_to?(:included_modules)
      next if cl.__singleton_class__?
      cl.included_modules.each { |mod| includers[mod] << [cl, true] }
      sc = cl.__singleton_class__
      sc.included_modules.each { |mod| includers[mod] << [cl, nil] }
    end
  end

  includers
end

Private Instance Methods

extended(other) click to toggle source
# File lib/robe/sash/includes_tracker.rb, line 67
def extended(other)
  IncludesTracker.reset!
  __orig_extended(other)
end
included(other) click to toggle source

Cannot hook into this method without :prepend.

# File lib/robe/sash/includes_tracker.rb, line 62
def included(other)
  IncludesTracker.reset!
  __orig_included(other)
end