module MarkMapper::Plugins::EmbeddedDocument

Attributes

_parent_document[RW]

Public Instance Methods

_root_document() click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 48
def _root_document
  @_root_document ||= _parent_document.try(:_root_document)
end
destroyed?() click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 25
def destroyed?
  !!_root_document.try(:destroyed?)
end
new?() click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 21
def new?
  _root_document.try(:new?) || @_new
end
persist(options={}) click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 42
def persist(options={})
  @_new = false
  clear_changes if respond_to?(:clear_changes)
  save_to_collection(options)
end
save(options={}) click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 29
def save(options={})
  _root_document.try(:save, options).tap do |result|
    persist(options) if result
  end
end
save!(options={}) click to toggle source
# File lib/mark_mapper/plugins/embedded_document.rb, line 35
def save!(options={})
  valid? || raise(DocumentNotValid.new(self))
  _root_document.try(:save!, options).tap do |result|
    persist(options) if result
  end
end