Parent

Files

Reference

Reference

Reference provides a way to access object indirectly. This allows for the object itself to be changed on the fly.

a = "HELLO"
b = ref(a)
b.to_s    #=> "HELLO"
c = 10
b.become(c)
b.to_s    #=> "10"

TODO: Use BasicObject for Ruby 1.9.

Public Class Methods

new(obj) click to toggle source
# File lib/facets/supplemental/facets/reference.rb, line 51
def self.new(obj)
  ref = allocate
  ref.become obj
  ref
end

Public Instance Methods

__value__() click to toggle source
# File lib/facets/supplemental/facets/reference.rb, line 67
def __value__
  @ref
end
Also aliased as: instance_delegate
become(obj) click to toggle source
# File lib/facets/supplemental/facets/reference.rb, line 61
def become(obj)
  old = @ref
  @ref = obj
  old
end
instance_delegate() click to toggle source
Alias for: __value__
method_missing(*args, &block) click to toggle source
# File lib/facets/supplemental/facets/reference.rb, line 57
def method_missing(*args, &block)
  @ref.__send__(*args, &block)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.