Sha256: e2fcc3ce591d4b69136d41a11f2659fd1463992e4951ee73910b542f3ea0cb2f

Contents?: true

Size: 482 Bytes

Versions: 52

Compression:

Stored size: 482 Bytes

Contents

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

52 entries across 52 versions & 3 rubygems

Version Path
mongo_mapper-unstable-2010.07.05 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.07.02 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.07.01 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.30 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.29 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.28 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.25 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.24 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-unstable-2010.06.23 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.2 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.1 lib/mongo_mapper/plugins/clone.rb
mongo_mapper-0.8.0 lib/mongo_mapper/plugins/clone.rb