Sha256: e05b0558ca036feeb0e8f24e44c6f72fd812fe5732670c0e00f32a77b5a263b9

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module Yoda
  module Store
    module Query
      module Associators
        class AssociateMethods
          # @return [Registry]
          attr_reader :registry

          # @param registry [Registry]
          def initialize(registry)
            @registry = registry
          end

          # @param obj [Object::Base]
          # @return [Enumerator<Objects::MethodObject>]
          def associate(obj)
            if obj.namespace?
              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.get(method_address)
                        yielder << el
                      end
                    end
                  end
                end
              end
            else
              []
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/store/query/associators/associate_methods.rb
yoda-language-server-0.10.0 lib/yoda/store/query/associators/associate_methods.rb
yoda-language-server-0.9.0 lib/yoda/store/query/associators/associate_methods.rb
yoda-language-server-0.8.0 lib/yoda/store/query/associators/associate_methods.rb