module Rake::Cloneable

  1. lib/rake/cloneable.rb
Parent: Rake

########################################################################## Mixin for creating easily cloned objects.

Methods

Public Instance

  1. dup
  2. clone

Public Instance methods

dup ()

Clone an object by making a new object and setting all the instance variables to the same values.

[show source]
    # File lib/rake/cloneable.rb, line 8
 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 ()
[show source]
    # File lib/rake/cloneable.rb, line 19
19:     def clone
20:       sibling = dup
21:       sibling.freeze if frozen?
22:       sibling
23:     end