Sha256: 115ab8818c50900229b48e573eccf98e29c6b57888e63e9ffa8d6b8402f70b6a

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

#--
# Reference
#
# Copyright (c) 2005 Thomas Sawyer
#
# 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.
#
# ==========================================================================
#  Revision History
# ==========================================================================
#  2005.06.12    trans
#  Changed name from Ref to Reference.
# ==========================================================================
#++

require 'blankslate'

#:title: Reference
#
#   TODO
#
# == Synopsis
#
#   a = "Hello"
#   b = ref(a)
#   b.upcase  #=> "HELLO"
#

class Reference < BlankSlate

  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
  alias_method :self, __value__

end


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



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#

# TODO

=begin #testing

  require 'test/unit'

=end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.9.0 lib/mega/reference.rb