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



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

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

#destroyed?Boolean

Returns:



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

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

#new?Boolean

Returns:



21
22
23
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 21

def new?
  _root_document.try(:new?) || @new
end

#save(options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 29

def save(options={})
  _root_document.try(:save, options).tap do |result|
    @new = false if result
  end
end

#save!(options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/mongo_mapper/plugins/embedded_document.rb', line 35

def save!(options={})
  _root_document.try(:save, options).tap do |result|
    @new = false if result
  end
end