Sha256: 67e9a61fd571efa002dc2b6bcac01e04cc3f636546b7e3809fef465a6ec20773

Contents?: true

Size: 928 Bytes

Versions: 5

Compression:

Stored size: 928 Bytes

Contents

# ===========================================================================
# Project:   Abbot - SproutCore Build Tools
# Copyright: ©2009 Apple Inc.
#            portions copyright @2006-2011 Strobe 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

5 entries across 5 versions & 1 rubygems

Version Path
sproutcore-1.5.0.pre.4.1 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.5.0.pre.4 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.5.0.pre.3 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.4.5 lib/sproutcore/buildfile/cloneable.rb
sproutcore-1.4.5-java lib/sproutcore/buildfile/cloneable.rb