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