Class: Looksee::LookupPath
- Inherits:
-
Object
- Object
- Looksee::LookupPath
- Defined in:
- lib/looksee/lookup_path.rb
Overview
Represents the method lookup path of an object, as a list of Entries.
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
List of Entry objects, each one representing a Module in the lookup path.
-
#object ⇒ Object
readonly
The object this lookup path represents.
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize(object) ⇒ LookupPath
constructor
A new instance of LookupPath.
-
#inspect(options = {}) ⇒ Object
Return a string showing the object’s lookup path.
Constructor Details
#initialize(object) ⇒ LookupPath
Returns a new instance of LookupPath.
7 8 9 10 |
# File 'lib/looksee/lookup_path.rb', line 7 def initialize(object) @object = object @entries = create_entries end |
Instance Attribute Details
#entries ⇒ Object (readonly)
List of Entry objects, each one representing a Module in the lookup path.
21 22 23 |
# File 'lib/looksee/lookup_path.rb', line 21 def entries @entries end |
#object ⇒ Object (readonly)
The object this lookup path represents.
15 16 17 |
# File 'lib/looksee/lookup_path.rb', line 15 def object @object end |
Instance Method Details
#find(name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/looksee/lookup_path.rb', line 23 def find(name) entries.each do |entry| visibility = entry.methods[name] or next if visibility == :undefined return nil else return Looksee.safe_call(Module, :instance_method, entry.module, name) end end nil end |