Permalink
Browse files

fix total entries function

  • Loading branch information...
ryanong committed Sep 12, 2011
1 parent a969d19 commit 5caf2e2e8d1b9794cbec0113563fa16c7d9be7f7
Showing with 2 additions and 3 deletions.
  1. +2 −3 lib/mongoid_spacial/spacial/geo_near_results.rb
@@ -5,13 +5,12 @@ class GeoNearResults < Array
attr_accessor :opts
def initialize(document,results,opts = {})
- raise "class must include Mongoid::Spacial::Document" unless document.respond_to?(:spacial_fields_indexed)
+ raise "#{document.name} class must include Mongoid::Spacial::Document" unless document.respond_to?(:spacial_fields_indexed)
@document = document
@opts = opts
@_original_opts = opts.clone
@stats = results['stats'] || {}
@opts[:skip] ||= 0
- @opts[:total_entries] = opts[:query]["num"] || @stats['nscanned']
@_original_array = results['results'].collect do |result|
res = Mongoid::Factory.from_db(@document, result.delete('obj'))
@@ -88,7 +87,7 @@ def reset
end
def total_entries
- @opts[:total_entries]
+ (@_paginated_array) ? @_paginated_array.count : @_original_array.count
end
alias_method :total_count, :total_entries

0 comments on commit 5caf2e2

Please sign in to comment.