Sha256: 075e53ffff1d1e32ee7af975cfe680396ad899499b0138567ef0446fc34d5c61
Contents?: true
Size: 824 Bytes
Versions: 2
Compression:
Stored size: 824 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: +true+ if validation passes, +false+ if not. def self.execute(doc, validate = true) return false if validate && !doc.valid? doc.run_callbacks :save do parent = doc._parent doc.new_record = false saved = if parent Save.execute(parent, validate) else doc.collection.save(doc.raw_attributes, :safe => Mongoid.persist_in_safe_mode) end return false unless saved end return true end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mongoid-2.0.0.alpha | lib/mongoid/commands/save.rb |
mongoid-pre-2.0.0.pre | lib/mongoid/commands/save.rb |