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