diff options
Diffstat (limited to 'jni/ruby/lib/rake/cloneable.rb')
-rw-r--r-- | jni/ruby/lib/rake/cloneable.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/jni/ruby/lib/rake/cloneable.rb b/jni/ruby/lib/rake/cloneable.rb new file mode 100644 index 0000000..d53645f --- /dev/null +++ b/jni/ruby/lib/rake/cloneable.rb @@ -0,0 +1,16 @@ +module Rake + ## + # Mixin for creating easily cloned objects. + + module Cloneable # :nodoc: + # The hook that is 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 + end + end +end |