Sha256: b03928da08d01974979a02ba70751aa329ce00581cf60254bdc39013ca397a77

Contents?: true

Size: 1.08 KB

Versions: 29

Compression:

Stored size: 1.08 KB

Contents

module Auth::Concerns::CloneConcern

	extend ActiveSupport::Concern

	included do 
		  ## overrides mongoid default clone method
  		## modified so that embedded objects are also cloned
  		## @return [Mongoid::Document] with all embedded documents assigned new ids.
  		def clone
        #puts " --------- COMING TO CLONE OVERRIDE ------------"
  			new_doc = super
=begin
        puts "Came past super."
        puts "self attributes are:"
        puts self.attributes
        new_doc.attributes.each do |attr|
          puts "doing attribute : #{attr}"
          attribute_name = attr[0]
          if attr.respond_to? :embedded_in
            puts "responds to embedded."
            mapped_docs = new_doc.send("#{attribute_name}").map {|k|
              puts "k older id is: #{k.id.to_s}"
              l = k.clone
              puts "k new id is: #{l.id.to_s}"
              l
            }
            new_doc.send("#{attribute_name}=",mapped_docs)
            #new_doc.send("#{attr}=",new_doc.send("#{attr}").map{|c| c = c.clone})
          end
        end
=end
  			new_doc
      end

	end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
wordjelly-auth-1.6.0 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.9 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.8 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.7 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.6 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.5 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.4 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.3 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.2 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.1 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.5.0 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.9 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.8 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.7 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.6 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.5 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.4 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.3 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.2 app/models/auth/concerns/clone_concern.rb
wordjelly-auth-1.4.0 app/models/auth/concerns/clone_concern.rb