Sha256: dd3bd45e0956a8b8772d489efc290de9621fccc0c291afa8c7b9507684c95f3d

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

#:title: Ref
#--
# Ref
# v 0.2
#
# Copyright (c) 2005 ?
#
# Ruby License
#
# This module is free software. You may use, modify, and/or redistribute this
# software under the same terms as Ruby.
# 
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
#
# $Id: ref.rb,v 0.2 2005/04/28 03:10:10 transami Exp $
#
# ==========================================================================
# Revision History ::
# YYYY.MM.DD  Ver. Dev.      Description
# --------------------------------------------------------------------------
# 2005.04.28  0.2  Trans     * Minor modifications to documentation.
# ==========================================================================
#++

# = Description
# 
# To do.
#

class Ref
   instance_methods.each{|m| undef_method(m)}

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

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

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

   def __value__() @ref end
end 


module Kernel
  def ref(x)
    Ref.new(x)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/ref.rb
facets-0.7.1 lib/facet/ref.rb
facets-0.7.2 lib/facet/ref.rb