module Rake::Cloneable
########################################################################## Mixin for creating easily cloned objects.
Public Instance Methods
Source
# File lib/rake/cloneable.rb 19 def clone 20 sibling = dup 21 sibling.freeze if frozen? 22 sibling 23 end
Source
# File lib/rake/cloneable.rb 8 def dup 9 sibling = self.class.new 10 instance_variables.each do |ivar| 11 value = self.instance_variable_get(ivar) 12 new_value = value.clone rescue value 13 sibling.instance_variable_set(ivar, new_value) 14 end 15 sibling.taint if tainted? 16 sibling 17 end
Clone an object by making a new object and setting all the instance variables to the same values.