Class: PeaceLove::Db
- Inherits:
-
Object
- Object
- PeaceLove::Db
- Defined in:
- lib/peace_love/db.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#mixins ⇒ Object
readonly
Returns the value of attribute mixins.
Instance Method Summary collapse
- #[](collection_name) ⇒ Object
- #collections ⇒ Object
-
#initialize(db, mixins) ⇒ Db
constructor
A new instance of Db.
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
#db ⇒ Object (readonly)
Returns the value of attribute db.
3 4 5 |
# File 'lib/peace_love/db.rb', line 3 def db @db end |
#mixins ⇒ Object (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 |
#collections ⇒ Object
10 11 12 |
# File 'lib/peace_love/db.rb', line 10 def collections @collections ||= {} end |