Sha256: 95a46af72482a88b25312972dff33c30ca88ea9b3753208d4c66a68f140a9e98

Contents?: true

Size: 626 Bytes

Versions: 24

Compression:

Stored size: 626 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 doc.valid?
        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

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-0.6.5 lib/mongoid/commands/save.rb
mongoid-0.6.4 lib/mongoid/commands/save.rb
mongoid-0.6.3 lib/mongoid/commands/save.rb
mongoid-0.6.2 lib/mongoid/commands/save.rb
mongoid-0.6.1 lib/mongoid/commands/save.rb
mongoid-0.6.0 lib/mongoid/commands/save.rb
mongoid-0.5.11 lib/mongoid/commands/save.rb
mongoid-0.5.10 lib/mongoid/commands/save.rb
mongoid-0.5.9 lib/mongoid/commands/save.rb
mongoid-0.5.8 lib/mongoid/commands/save.rb
mongoid-0.5.7 lib/mongoid/commands/save.rb
mongoid-0.5.6 lib/mongoid/commands/save.rb
mongoid-0.5.5 lib/mongoid/commands/save.rb
mongoid-0.5.4 lib/mongoid/commands/save.rb
mongoid-0.5.3 lib/mongoid/commands/save.rb
mongoid-0.5.2 lib/mongoid/commands/save.rb
mongoid-0.5.1 lib/mongoid/commands/save.rb
mongoid-0.5.0 lib/mongoid/commands/save.rb
mongoid-0.4.8 lib/mongoid/commands/save.rb
mongoid-0.4.7 lib/mongoid/commands/save.rb