Class: Reference

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

__value__ become instance_delegate method_missing new

### Public Class methods

new(obj)

[Source]

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

### Public Instance methods

__value__()

[Source]

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

become(obj)

[Source]

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

instance_delegate()

Alias for #value

method_missing(*args, &block)

[Source]

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

[Validate]