Sha256: fca2d7c1fe01a9240ee95aeb7ab5648fc7ccbad2a8f75ded71991f20ead556a3

Contents?: true

Size: 637 Bytes

Versions: 18

Compression:

Stored size: 637 Bytes

Contents

module Mongoid #:nodoc:
  module Commands
    class Save
      # Performs a save of the supplied +Document+, handling all associated
      # callbacks and validation.
      #
      # Options:
      #
      # doc: A +Document+ that is going to be persisted.
      #
      # Returns: +Document+ if validation passes, +false+ if not.
      def self.execute(doc)
        return false unless Validate.execute(doc)
        doc.run_callbacks :before_save
        parent = doc.parent
        parent ? Save.execute(parent) : doc.collection.save(doc.attributes)
        doc.run_callbacks :after_save
        return doc
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongoid-0.8.2 lib/mongoid/commands/save.rb
mongoid-0.8.1 lib/mongoid/commands/save.rb
mongoid-0.7.10 lib/mongoid/commands/save.rb
mongoid-0.7.9 lib/mongoid/commands/save.rb
mongoid-0.7.8 lib/mongoid/commands/save.rb
mongoid-0.7.7 lib/mongoid/commands/save.rb
mongoid-0.7.6 lib/mongoid/commands/save.rb
mongoid-0.7.5 lib/mongoid/commands/save.rb
mongoid-0.7.4 lib/mongoid/commands/save.rb
mongoid-0.7.3 lib/mongoid/commands/save.rb
mongoid-0.7.2 lib/mongoid/commands/save.rb
mongoid-0.7.1 lib/mongoid/commands/save.rb
mongoid-0.7.0 lib/mongoid/commands/save.rb
mongoid-0.6.10 lib/mongoid/commands/save.rb
mongoid-0.6.9 lib/mongoid/commands/save.rb
mongoid-0.6.8 lib/mongoid/commands/save.rb
mongoid-0.6.7 lib/mongoid/commands/save.rb
mongoid-0.6.6 lib/mongoid/commands/save.rb