Class: Yoda::Store::Query::Associators::AssociateMethods
- Inherits:
-
Object
- Object
- Yoda::Store::Query::Associators::AssociateMethods
- Defined in:
- lib/yoda/store/query/associators/associate_methods.rb
Instance Attribute Summary collapse
- #registry ⇒ Registry readonly
Instance Method Summary collapse
- #associate(obj) ⇒ Enumerator<Objects::MethodObject>
-
#initialize(registry) ⇒ AssociateMethods
constructor
A new instance of AssociateMethods.
Constructor Details
#initialize(registry) ⇒ AssociateMethods
Returns a new instance of AssociateMethods.
10 11 12 |
# File 'lib/yoda/store/query/associators/associate_methods.rb', line 10 def initialize(registry) @registry = registry end |
Instance Attribute Details
#registry ⇒ Registry (readonly)
7 8 9 |
# File 'lib/yoda/store/query/associators/associate_methods.rb', line 7 def registry @registry end |
Instance Method Details
#associate(obj) ⇒ Enumerator<Objects::MethodObject>
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yoda/store/query/associators/associate_methods.rb', line 16 def associate(obj) if obj.is_a?(Objects::NamespaceObject) Enumerator.new do |yielder| name_set = Set.new AssociateAncestors.new(registry).associate(obj).each do |ancestor| ancestor.instance_method_addresses.each do |method_address| method_name = Objects::MethodObject.name_of_path(method_address) if !name_set.member?(method_name) name_set.add(method_name) if el = registry.find(method_address) yielder << el end end end end end else [] end end |