aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rake/cloneable.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-15 21:59:37 +0000
commit9c66bad9f3d522d50d4a45ef8a3a92abbf93229f (patch)
tree8fc1ae219e41bdd711442b1d35149da4f45dfa8a /lib/rake/cloneable.rb
parentbfc95c6e1639edc909338ef4d20d990caf6f630e (diff)
downloadruby-9c66bad9f3d522d50d4a45ef8a3a92abbf93229f.tar.gz
* lib/rake*: Updated to rake 0.9.3
* test/rake*: ditto * bin/rake: ditto * NEWS: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rake/cloneable.rb')
-rw-r--r--lib/rake/cloneable.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/rake/cloneable.rb b/lib/rake/cloneable.rb
index 19c780bff6..ac67471232 100644
--- a/lib/rake/cloneable.rb
+++ b/lib/rake/cloneable.rb
@@ -3,23 +3,14 @@ module Rake
# Mixin for creating easily cloned objects.
#
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)
+ # The hook that invoked by 'clone' and 'dup' methods.
+ def initialize_copy(source)
+ super
+ source.instance_variables.each do |var|
+ src_value = source.instance_variable_get(var)
+ value = src_value.clone rescue src_value
+ instance_variable_set(var, value)
end
- sibling.taint if tainted?
- sibling
- end
-
- def clone
- sibling = dup
- sibling.freeze if frozen?
- sibling
end
end
end