Class: Tutor::Attributes::Blocks::Instance::Writer
- Inherits:
-
Tutor::Attributes::Block
- Object
- Tutor::Attributes::Block
- Tutor::Attributes::Blocks::Instance::Writer
- Defined in:
- lib/tutor/attributes/blocks/instance/writer.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Writer
constructor
A new instance of Writer.
Constructor Details
#initialize(name) ⇒ Writer
Returns a new instance of Writer.
5 6 7 8 9 10 11 12 |
# File 'lib/tutor/attributes/blocks/instance/writer.rb', line 5 def initialize(name) self.tap do |block| @name = name super() do |object, value| object.instance_variable_set("@#{block.name.to_s}".to_sym, value) end end end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/tutor/attributes/blocks/instance/writer.rb', line 3 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/tutor/attributes/blocks/instance/writer.rb', line 3 def name @name end |