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
Methods
Public Instance methods
clone() [ source ]
copy() [ source ]

if object/copy has been required?

This method is also aliased as deep_copy
deep_copy()

Alias for copy

dup() [ source ]