Class: RBS::DefinitionBuilder::MethodBuilder::Methods
- Inherits:
-
Object
- Object
- RBS::DefinitionBuilder::MethodBuilder::Methods
- Defined in:
- lib/rbs/definition_builder/method_builder.rb
Defined Under Namespace
Classes: Sorter
Constant Summary collapse
- Definition =
_ = Struct.new(:name, :type, :originals, :overloads, :accessibilities, keyword_init: true) do # @implements Definition def original originals.first end def accessibility if original.is_a?(AST::Members::Alias) raise "alias member doesn't have accessibility" else accessibilities[0] or raise end end def self.empty(name:, type:) new(type: type, name: name, originals: [], overloads: [], accessibilities: []) end end
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(type:) ⇒ Methods
constructor
A new instance of Methods.
- #validate! ⇒ Object
Constructor Details
#initialize(type:) ⇒ Methods
Returns a new instance of Methods.
28 29 30 31 |
# File 'lib/rbs/definition_builder/method_builder.rb', line 28 def initialize(type:) @type = type @methods = {} end |
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
26 27 28 |
# File 'lib/rbs/definition_builder/method_builder.rb', line 26 def methods @methods end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/rbs/definition_builder/method_builder.rb', line 25 def type @type end |
Instance Method Details
#each ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rbs/definition_builder/method_builder.rb', line 47 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! ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rbs/definition_builder/method_builder.rb', line 33 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 |