Class: Wee::ValueHolder

Inherits:
Object show all
Defined in:
lib/wee/core/valueholder.rb

Overview

Implements a value holder. Useful for backtracking the reference assigned to an instance variable (not the object itself!). An example where this is used is the @__decoration attribute of class Wee::Component.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil) ⇒ ValueHolder

Returns a new instance of ValueHolder.



8
9
10
# File 'lib/wee/core/valueholder.rb', line 8

def initialize(value=nil)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/wee/core/valueholder.rb', line 6

def value
  @value
end

Instance Method Details

#restore_snapshot(value) ⇒ Object



16
17
18
# File 'lib/wee/core/valueholder.rb', line 16

def restore_snapshot(value)
  @value = value
end

#take_snapshotObject



12
13
14
# File 'lib/wee/core/valueholder.rb', line 12

def take_snapshot
  @value
end