123456789_123456789_123456789_123456789_123456789_

Class: RBS::DefinitionBuilder::MethodBuilder::Methods

Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: lib/rbs/definition_builder/method_builder.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(type:) ⇒ Methods

[ GitHub ]

  
# File 'lib/rbs/definition_builder/method_builder.rb', line 30

def initialize(type:)
  @type = type
  @methods = {}
end

Instance Attribute Details

#methods (readonly)

[ GitHub ]

  
# File 'lib/rbs/definition_builder/method_builder.rb', line 28

attr_reader :methods

#type (readonly)

[ GitHub ]

  
# File 'lib/rbs/definition_builder/method_builder.rb', line 27

attr_reader :type

Instance Method Details

#each

[ GitHub ]

  
# File 'lib/rbs/definition_builder/method_builder.rb', line 49

def each
  if block_given?
    Sorter.new(methods).each_strongly_connected_component do |scc|
      if scc.size > 1
        raise RecursiveAliasDefinitionError.new(type: type, defs: scc)
      end

      yield scc[0]
    end
  else
    enum_for :each
  end
end

#validate!

[ GitHub ]

  
# File 'lib/rbs/definition_builder/method_builder.rb', line 35

def validate!
  methods.each_value do |defn|
    if defn.originals.size > 1
      raise DuplicatedMethodDefinitionError.new(
        type: type,
        method_name: defn.name,
        members: defn.originals
      )
    end
  end

  self
end