Class: Morel::Collection
- Inherits:
-
Object
- Object
- Morel::Collection
- Defined in:
- lib/morel/collection.rb,
lib/morel/sorted_window.rb
Constant Summary collapse
- OPERATIONS =
[ :insert, :find_one, :map_reduce ]
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #db ⇒ Object
- #delete ⇒ Object
- #first ⇒ Object
-
#initialize(name) ⇒ Collection
constructor
A new instance of Collection.
- #sorted_window(size, &block) ⇒ Object
Constructor Details
#initialize(name) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 |
# File 'lib/morel/collection.rb', line 8 def initialize name @name = name @collection = db.create_collection(name) end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
6 7 8 |
# File 'lib/morel/collection.rb', line 6 def collection @collection end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/morel/collection.rb', line 6 def name @name end |
Class Method Details
.db=(db) ⇒ Object
16 17 18 |
# File 'lib/morel/collection.rb', line 16 def self.db= db @@db = db end |
Instance Method Details
#db ⇒ Object
13 14 15 |
# File 'lib/morel/collection.rb', line 13 def db @@db end |
#delete ⇒ Object
20 21 22 |
# File 'lib/morel/collection.rb', line 20 def delete db.drop_collection(name) end |
#first ⇒ Object
24 25 26 |
# File 'lib/morel/collection.rb', line 24 def first find_one end |
#sorted_window(size, &block) ⇒ Object
6 7 8 |
# File 'lib/morel/sorted_window.rb', line 6 def sorted_window size, &block SortedWindow.new(:collection => self, :size => size, :block => block) end |