Sha256: 152d57993090725c774a0687b2f6c17e88c5664ae640a7c113045643b55a025b

Contents?: true

Size: 604 Bytes

Versions: 6

Compression:

Stored size: 604 Bytes

Contents

# encoding: UTF-8
module MongoMapper
  module Plugins
    module Clone
      module InstanceMethods
        def initialize_copy(other)
          @_new       = true
          @_destroyed = false
          default_id_value({})
          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
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
jonbell-mongo_mapper-0.8.6 lib/mongo_mapper/plugins/clone.rb
ssherman-mongo_mapper-0.8.6 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.6 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.5 lib/mongo_mapper/plugins/clone.rb
honkster-mongo_mapper-0.8.4 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.4 lib/mongo_mapper/plugins/clone.rb