Module: MongoMapper::Plugins::Clone
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document, EmbeddedDocument
- Defined in:
- lib/mongo_mapper/plugins/clone.rb
Instance Method Summary collapse
Instance Method Details
#initialize_copy(other) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mongo_mapper/plugins/clone.rb', line 7 def initialize_copy(other) @_new = true @_destroyed = false @_id = nil 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 |