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) ⇒ Object

Parameters:

  • obj (Object::Base)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yoda/store/query/associators/associate_methods.rb', line 15

def associate(obj)
  if obj.is_a?(Objects::NamespaceObject)
    AssociateMethods.new(registry).associate(obj)
    obj.methods = Enumerator.new do |yielder|
      name_set = Set.new

      obj.ancestors.each do |ancestor|
        ancestor.instance_method_addresses.each do |method_address|
          method_name = Objects::MethodObject.name_of_path(method_address)
          next name_set.has_key?(method_name)
          name_set.add(method_name)
          if el = registry.find(method_address)
            yielder << el
          end
        end
      end
    end
  end
end