Sha256: a749224855f07c0652b0942a5daaa6603fcad7dd12f00501165aa4f11da81b22
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
#:title: NotCopyable #-- # NotCopyable # v 1.0 # # (Adapted from Ruby Treasures 0.4) # # Copyright (C) 2002 Paul Brannan <paul@atdesk.com> # # 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: notcopyable.rb,v 1.0 2005/04/28 03:10:10 transami Exp $ # # ========================================================================== # Revision History :: # YYYY.MM.DD Ver. Dev. Description # -------------------------------------------------------------------------- # 2005.04.28 1.0 Trans * Minor modifications to documentation. # ========================================================================== # To Do :: # * If one is reopening a class and including this, it will # not work if the class defined #dub, #clone or #copy (and #deep_copy) # itself. It only work if it's ancestors are responsible for those # methods. How to fix? # ========================================================================== #++ # = Description # # Disable copying via dup and clone (and copy). # # == Usage # # require 'carat/notcopyable.rb' # # Class FixedString < String # include NotCopyable # end # # s = FixedString.new("Don't tred on me!") # puts s # s2 = s.dup # # produces # # Don't tred on me! # TypeError, "Object not copyable" # # == Notes # # * I don't think this will prove very useful, but just in case # here it is. # # == Author(s) # # * Paul Brannan <paul at atdesk.com> # * Thomas Sawyer # module NotCopyable VERSION = '1.0.0' def clone raise TypeError, "Object not copyable" end def dup raise TypeError, "Object not copyable" end # if object/copy has been required? def copy raise TypeError, "Object not copyable" end alias_method( :deep_copy, :copy ) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.0 | lib/facet/notcopyable.rb |
facets-0.7.1 | lib/facet/notcopyable.rb |
facets-0.7.2 | lib/facet/notcopyable.rb |