Sha256: 4e15fbf016500bc87d6a93dfe5e10e5332ae4fc1ec1e863eaebc4a1d278ff6f5

Contents?: true

Size: 943 Bytes

Versions: 17

Compression:

Stored size: 943 Bytes

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2009 Sprout Systems, Inc.
#            and contributors
# ===========================================================================

module SC
  
  # Mixing for creating easily cloned objects.  Borrowed from Rake 0.8.3
  module Cloneable

    # Clone an object by making a new object and setting all the instance
    # variables to the same values.
    def dup
      sibling = self.class.new
      instance_variables.each do |ivar|
        value = self.instance_variable_get(ivar)
        new_value = value.clone rescue value
        sibling.instance_variable_set(ivar, new_value)
      end
      sibling.taint if tainted?
      sibling
    end

    def clone
      sibling = dup
      sibling.freeze if frozen?
      sibling
    end
  end
  
  
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1046 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1043 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1042 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1037 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1035 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1031 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1030 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1029 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1027 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1028 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1026 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1025 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1024 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1009 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1008 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.0.1003 lib/sproutcore/buildfile/cloneable.rb