Module: MongoMapper::Plugins::EmbeddedDocument::InstanceMethods

Defined in:
lib/mongo_mapper/plugins/embedded_document.rb

Instance Method Summary collapse

Instance Method Details

#_parent_document=(value) ⇒ Object



42
43
44
45
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 42

def _parent_document=(value)
  @_root_document   = value._root_document
  @_parent_document = value
end

#destroyed?Boolean

Returns:



26
27
28
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 26

def destroyed?
  !!_root_document.try(:destroyed?)
end

#new?Boolean

Returns:



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(options={})
  _root_document.try(:save, options).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!(options={})
  _root_document.try(:save, options).tap do |result|
    @_new = false if result
  end
end