1module Rake 2 # ########################################################################## 3 # Mixin for creating easily cloned objects. 4 # 5 module Cloneable 6 # The hook that invoked by 'clone' and 'dup' methods. 7 def initialize_copy(source) 8 super 9 source.instance_variables.each do |var| 10 src_value = source.instance_variable_get(var) 11 value = src_value.clone rescue src_value 12 instance_variable_set(var, value) 13 end 14 end 15 end 16end 17