Module: MongoMapper::Plugins::EmbeddedDocument::InstanceMethods
- Defined in:
- lib/mongo_mapper/plugins/embedded_document.rb
Instance Method Summary collapse
- #_root_document ⇒ Object
- #destroyed? ⇒ Boolean
- #new? ⇒ Boolean
- #save(options = {}) ⇒ Object
- #save!(options = {}) ⇒ Object
Instance Method Details
#_root_document ⇒ Object
42 43 44 |
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 42 def _root_document @_root_document ||= _parent_document.try(:_root_document) end |
#destroyed? ⇒ Boolean
26 27 28 |
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 26 def destroyed? !!_root_document.try(:destroyed?) end |
#new? ⇒ Boolean
22 23 24 |
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 22 def new? _root_document.try(:new?) || @_new end |
#save(options = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 30 def save(={}) _root_document.try(:save, ).tap do |result| @_new = false if result end end |
#save!(options = {}) ⇒ Object
36 37 38 39 40 |
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 36 def save!(={}) _root_document.try(:save, ).tap do |result| @_new = false if result end end |