Class: CompositeCursor

Inherits:
Object
  • Object
show all
Includes:
Enumerable, FromHash
Defined in:
lib/mongo_delegate/composite_cursor.rb

Defined Under Namespace

Classes: FindOps

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#uniq_by

Instance Attribute Details

#collsObject

Returns the value of attribute colls.



62
63
64
# File 'lib/mongo_delegate/composite_cursor.rb', line 62

def colls
  @colls
end

#optionsObject

Returns the value of attribute options.



62
63
64
# File 'lib/mongo_delegate/composite_cursor.rb', line 62

def options
  @options
end

#selectorObject

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

#countObject



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

#firstObject



91
92
93
# File 'lib/mongo_delegate/composite_cursor.rb', line 91

def first
  rows.first
end

#sort_procObject



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_afObject



65
# File 'lib/mongo_delegate/composite_cursor.rb', line 65

def to_af; rows; end