Class: Literal::Attributable::Generators::Writer
- Defined in:
- lib/literal/attributable/generators/writer.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Nodes
Instance Method Summary collapse
- #body ⇒ Object private
-
#initialize(attribute) ⇒ Writer
constructor
A new instance of Writer.
- #params ⇒ Object private
- #template ⇒ Object
- #type_check ⇒ Object private
Methods inherited from Base
Methods included from Nodes
Constructor Details
#initialize(attribute) ⇒ Writer
Returns a new instance of Writer.
5 6 7 |
# File 'lib/literal/attributable/generators/writer.rb', line 5 def initialize(attribute) @attribute = attribute end |
Instance Method Details
#body ⇒ Object (private)
29 30 31 |
# File 'lib/literal/attributable/generators/writer.rb', line 29 def body [type_check, assignment] end |
#params ⇒ Object (private)
20 21 22 23 24 25 26 27 |
# File 'lib/literal/attributable/generators/writer.rb', line 20 def params [ PositionalParam.new( name: "value", default: nil ) ] end |
#template ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/literal/attributable/generators/writer.rb', line 9 def template Def.new( visibility: @attribute.writer, name: "#{@attribute.name}=", params:, body: ) end |
#type_check ⇒ Object (private)
33 34 35 36 37 38 |
# File 'lib/literal/attributable/generators/writer.rb', line 33 def type_check TypeCheck.new( attribute_name: @attribute.name, variable_name: "value" ) end |