Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (22 sloc) 0.667 kb
# encoding: UTF-8
module MongoMapper
module Plugins
module Clone
extend ActiveSupport::Concern
def initialize_copy(other)
@_new = true
@_destroyed = false
@_id = nil
remove_instance_variable(:"@_read__id") if instance_variable_defined? (:"@_read__id")
associations.each do |name, association|
instance_variable_set(association.ivar, nil)
end
self.attributes = other.attributes.clone.except(:_id).inject({}) do |hash, entry|
key, value = entry
hash[key] = value.duplicable? ? value.clone : value
hash
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.