class Variable::IVar
Shared variable that can be written at most once
ignore :reek:InstanceVariableAssumption
Public Instance Methods
populate_with() { || ... }
click to toggle source
Populate and return value, use block to compute value if empty
The block is guaranteed to be executed at max once.
Subsequent reads are guaranteed to return the block value.
@return [Object]
# File lib/variable.rb, line 250 def populate_with return @value if full? synchronize do perform_put(yield) if empty? end @value end
put(value)
click to toggle source
Put value, raises if already full
@param [Object] value
@return [self]
@raise Error
if already full
# File lib/variable.rb, line 234 def put(value) synchronize do fail Error, 'is immutable' if full? perform_put(value) end self end
Private Instance Methods
perform_take()
click to toggle source
Perform take operation
@return [Object]
# File lib/variable.rb, line 265 def perform_take @value end