Sha256: 23e884d1ea2e6b00860bc5b5514ed4eb13f0fcb4117f771389f05ee0d7a767d7
Contents?: true
Size: 768 Bytes
Versions: 5
Compression:
Stored size: 768 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, validate = true) return false if validate && !doc.valid? doc.run_callbacks :before_save parent = doc._parent doc.new_record = false if parent ? Save.execute(parent, validate) : doc.collection.save(doc.attributes) doc.run_callbacks :after_save return true else return false end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems