Class: Democritus::ClassBuilder::Commands::Attribute
- Inherits:
-
Democritus::ClassBuilder::Command
- Object
- Democritus::ClassBuilder::Command
- Democritus::ClassBuilder::Commands::Attribute
- Defined in:
- lib/democritus/class_builder/commands/attribute.rb
Overview
Command to assign an attribute to the given built class.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#call ⇒ Object
:reek:NestedIterators: { exclude: [ ‘Democritus::ClassBuilder::Commands::Attribute#call’ ] }.
-
#initialize(name:, **options) ⇒ Attribute
constructor
A new instance of Attribute.
Methods inherited from Democritus::ClassBuilder::Command
Constructor Details
#initialize(name:, **options) ⇒ Attribute
Returns a new instance of Attribute.
8 9 10 11 12 |
# File 'lib/democritus/class_builder/commands/attribute.rb', line 8 def initialize(name:, **) self.builder = .fetch(:builder) self.name = name self. = end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/democritus/class_builder/commands/attribute.rb', line 14 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/democritus/class_builder/commands/attribute.rb', line 14 def end |
Instance Method Details
#call ⇒ Object
:reek:NestedIterators: { exclude: [ ‘Democritus::ClassBuilder::Commands::Attribute#call’ ] }
17 18 19 20 21 22 23 24 25 |
# File 'lib/democritus/class_builder/commands/attribute.rb', line 17 def call defer do |subject| subject.module_exec(@name) do |name| attr_reader name private attr_writer name end end end |