Method: LibGems::Specification#initialize_copy

Defined in:
lib/libgems/specification.rb

#initialize_copy(other_spec) ⇒ Object

Duplicates array_attributes from other_spec so state isn’t shared.



433
434
435
436
437
438
439
440
441
442
443
# File 'lib/libgems/specification.rb', line 433

def initialize_copy(other_spec)
  other_ivars = other_spec.instance_variables
  other_ivars = other_ivars.map { |ivar| ivar.intern } if # for 1.9
    other_ivars.any? { |ivar| String === ivar }

  self.class.array_attributes.each do |name|
    name = :"@#{name}"
    next unless other_ivars.include? name
    instance_variable_set name, other_spec.instance_variable_get(name).dup
  end
end