Class: Yoda::Store::Query::Associators::AssociateMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/query/associators/associate_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry) ⇒ AssociateMethods

Returns a new instance of AssociateMethods.

Parameters:



10
11
12
# File 'lib/yoda/store/query/associators/associate_methods.rb', line 10

def initialize(registry)
  @registry = registry
end

Instance Attribute Details

#registryRegistry (readonly)

Returns:



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>

Parameters:

  • obj (Object::Base)

Returns:



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