Sha256: e184096c72c71857e90f6345c9c96a642617318cd088b9a028ade6f54bb8d62e
Contents?: true
Size: 784 Bytes
Versions: 2
Compression:
Stored size: 784 Bytes
Contents
# encoding: utf-8 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 if parent Save.execute(parent) else collection = doc.collection collection ? collection.save(doc.attributes) : raise(MissingParentError.new(doc)) end doc.run_callbacks :after_save return true end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid-0.9.8 | lib/mongoid/commands/save.rb |
mongoid-0.9.7 | lib/mongoid/commands/save.rb |