Class: Tutor::Attributes::Blocks::Instance::Writer

Inherits:
Tutor::Attributes::Block show all
Defined in:
lib/tutor/attributes/blocks/instance/writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/tutor/attributes/blocks/instance/writer.rb', line 3

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/tutor/attributes/blocks/instance/writer.rb', line 3

def name
  @name
end