Class: RBI::AttrAccessor
- Inherits:
-
Attr
show all
- Extended by:
- T::Sig
- Defined in:
- lib/rbi/model.rb,
lib/rbi/rewriters/merge_trees.rb
Instance Attribute Summary
Attributes inherited from Attr
#names, #sigs, #visibility
#comments
Attributes inherited from Node
#loc, #parent_tree
Instance Method Summary
collapse
Methods inherited from Attr
#accept_printer, #index_ids, #merge_with, #oneline?
Methods included from Indexable
#index_ids
#merge_with, #oneline?
Methods inherited from Node
#accept_printer, #detach, #group_kind, #merge_with, #oneline?, #parent_conflict_tree, #parent_scope, #print, #replace, #string
Constructor Details
#initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block) ⇒ AttrAccessor
378
379
380
381
|
# File 'lib/rbi/model.rb', line 378
def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: )
block&.call(self)
end
|
Instance Method Details
#compatible_with?(other) ⇒ Boolean
420
421
422
|
# File 'lib/rbi/rewriters/merge_trees.rb', line 420
def compatible_with?(other)
other.is_a?(AttrAccessor) && super
end
|
#fully_qualified_names ⇒ Object
384
385
386
387
|
# File 'lib/rbi/model.rb', line 384
def fully_qualified_names
parent_name = parent_scope&.fully_qualified_name
names.flat_map { |name| ["#{parent_name}##{name}", "#{parent_name}##{name}="] }
end
|
#to_s ⇒ Object
390
391
392
393
|
# File 'lib/rbi/model.rb', line 390
def to_s
symbols = names.map { |name| ":#{name}" }.join(", ")
"#{parent_scope&.fully_qualified_name}.attr_accessor(#{symbols})"
end
|