Module: MongoMapper::EmbeddedDocument::InstanceMethods

Defined in:
lib/mongo_mapper/embedded_document.rb

Instance Method Summary collapse

Instance Method Details

#_parent_document=(value) ⇒ Object



65
66
67
68
# File 'lib/mongo_mapper/embedded_document.rb', line 65

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

#destroyed?Boolean

Returns:



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

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

#new?Boolean

Returns:



47
48
49
# File 'lib/mongo_mapper/embedded_document.rb', line 47

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

#save(options = {}) ⇒ Object



51
52
53
54
55
56
# File 'lib/mongo_mapper/embedded_document.rb', line 51

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

#save!(options = {}) ⇒ Object



58
59
60
61
62
63
# File 'lib/mongo_mapper/embedded_document.rb', line 58

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