Class: Reference

Inherits:
Object show all
Defined in:
lib/mega/reference.rb

Overview

:title: Reference

TODO

Synopsis

a = "Hello"
b = ref(a)
b.upcase  #=> "HELLO"

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



45
46
47
# File 'lib/mega/reference.rb', line 45

def method_missing(*args, &block)
  @ref.__send__(*args, &block)
end

Class Method Details

.new(obj) ⇒ Object



39
40
41
42
43
# File 'lib/mega/reference.rb', line 39

def self.new(obj)
  ref = allocate
  ref.become obj
  ref
end

Instance Method Details

#__value__Object



55
56
57
# File 'lib/mega/reference.rb', line 55

def __value__
  @ref
end

#become(obj) ⇒ Object



49
50
51
52
53
# File 'lib/mega/reference.rb', line 49

def become(obj)
  old = @ref
  @ref = obj
  old
end