Class: PeaceLove::Db

Inherits:
Object
  • Object
show all
Defined in:
lib/peace_love/db.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, mixins) ⇒ Db

Returns a new instance of Db.



5
6
7
8
# File 'lib/peace_love/db.rb', line 5

def initialize(db,mixins)
  @db = db || raise("#{self} requires a non-nil db")
  @mixins = mixins
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



3
4
5
# File 'lib/peace_love/db.rb', line 3

def db
  @db
end

#mixinsObject (readonly)

Returns the value of attribute mixins.



3
4
5
# File 'lib/peace_love/db.rb', line 3

def mixins
  @mixins
end

Instance Method Details

#[](collection_name) ⇒ Object



14
15
16
# File 'lib/peace_love/db.rb', line 14

def [](collection_name)
  collections[collection_name] ||= PeaceLove::Collection.new( db[collection_name], mixins[collection_name] )
end

#collectionsObject



10
11
12
# File 'lib/peace_love/db.rb', line 10

def collections
  @collections ||= {}
end