Class: CompositeCursor
- Inherits:
-
Object
- Object
- CompositeCursor
- Includes:
- Enumerable, FromHash
- Defined in:
- lib/mongo_delegate/composite_cursor.rb
Defined Under Namespace
Classes: FindOps
Instance Attribute Summary collapse
-
#colls ⇒ Object
Returns the value of attribute colls.
-
#options ⇒ Object
Returns the value of attribute options.
-
#selector ⇒ Object
Returns the value of attribute selector.
Instance Method Summary collapse
Methods included from Enumerable
Instance Attribute Details
#colls ⇒ Object
Returns the value of attribute colls.
62 63 64 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 62 def colls @colls end |
#options ⇒ Object
Returns the value of attribute options.
62 63 64 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 62 def @options end |
#selector ⇒ Object
Returns the value of attribute selector.
62 63 64 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 62 def selector @selector end |
Instance Method Details
#count ⇒ Object
86 87 88 89 90 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 86 def count colls.map do |coll| coll.scope_ne('_duplicate' => true).find(selector).count end.sum end |
#each(&b) ⇒ Object
83 84 85 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 83 def each(&b) rows.each(&b) end |
#first ⇒ Object
91 92 93 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 91 def first rows.first end |
#sort_proc ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 66 def sort_proc foc = cursors.first.foc return nil unless foc lambda do |doc| foc.map { |k,v| (v == 1) ? doc[k] : doc[k].sortflip } end end |
#to_af ⇒ Object
65 |
# File 'lib/mongo_delegate/composite_cursor.rb', line 65 def to_af; rows; end |