Class Reference
In: lib/facets/supplemental/facets/reference.rb
Parent: Object

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.

Methods

Public Class methods

[Source]

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

Public Instance methods

[Source]

# File lib/facets/supplemental/facets/reference.rb, line 67
  def __value__
    @ref
  end

[Source]

# File lib/facets/supplemental/facets/reference.rb, line 61
  def become(obj)
    old = @ref
    @ref = obj
    old
  end
instance_delegate()

Alias for #value

[Source]

# File lib/facets/supplemental/facets/reference.rb, line 57
  def method_missing(*args, &block)
    @ref.__send__(*args, &block)
  end

[Validate]