Class Reference
In: lib/more/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)
  puts b    #=> "HELLO"
  c = 10
  b.become(c)
  puts b    #=> "10"

Methods

Public Class methods

[Source]

    # File lib/more/facets/reference.rb, line 50
50:   def self.new(obj)
51:     ref = allocate
52:     ref.become obj
53:     ref
54:   end

Public Instance methods

[Source]

    # File lib/more/facets/reference.rb, line 66
66:   def __value__
67:     @ref
68:   end

[Source]

    # File lib/more/facets/reference.rb, line 60
60:   def become(obj)
61:     old = @ref
62:     @ref = obj
63:     old
64:   end
instance_delegate()

Alias for #value

[Source]

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

[Validate]