Class: Mongoo::Embedded::Base

Inherits:
Core
  • Object
show all
Defined in:
lib/mongoo/embedded/base.rb

Instance Method Summary collapse

Methods inherited from Core

describe, #merge!, #mongohash, #persisted_mongohash, #reset_persisted_mongohash, #to_hash

Constructor Details

#initialize(parent, hash = {}, key = nil) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
# File 'lib/mongoo/embedded/base.rb', line 5

def initialize(parent, hash={}, key=nil)
  @parent    = parent
  @persisted = persisted?
  @key       = key
  init_from_hash(hash)
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
# File 'lib/mongoo/embedded/base.rb', line 32

def ==(other)
  to_hash == other.to_hash
end

#collection_nameObject



28
29
30
# File 'lib/mongoo/embedded/base.rb', line 28

def collection_name
  @parent.collection_name
end

#connObject



24
25
26
# File 'lib/mongoo/embedded/base.rb', line 24

def conn
  @parent.conn
end

#dbObject



20
21
22
# File 'lib/mongoo/embedded/base.rb', line 20

def db
  @parent.db
end

#keyObject



12
13
14
# File 'lib/mongoo/embedded/base.rb', line 12

def key
  @key
end

#persisted?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mongoo/embedded/base.rb', line 16

def persisted?
  @parent.persisted?
end