Skip to content

Commit

Permalink
Store total counts on FetchingArray when fb returns a "count" attribute
Browse files Browse the repository at this point in the history
Previously we were accessing the FetchingArray.count method, which was
returning the number of entries currently in the array, rather than the
total number of available entries. When displaying statistics, this
makes our numbers look small and sad.

When building a fetching array we now store a "count" attribute if
present in the total_count attribute.
  • Loading branch information
Lilia Markham authored and Adam Derewecki committed Apr 17, 2012
1 parent 410402e commit 5348148
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/mogli/client.rb
Expand Up @@ -177,6 +177,7 @@ def extract_fetching_array(hash,klass)
f.concat(hash["data"])
f.client = self
f.classes = Array(klass)
f.total_count = hash["count"]
if paging=hash["paging"]
f.next_url = URI.encode paging["next"] unless paging["next"].nil?
f.previous_url = URI.encode paging["previous"] unless paging["previous"].nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/mogli/fetching_array.rb
@@ -1,6 +1,6 @@
module Mogli
class FetchingArray < Array
attr_accessor :next_url, :previous_url, :client, :classes
attr_accessor :next_url, :previous_url, :client, :classes, :total_count

def fetch_next
return [] if next_url.nil? || next_url.empty?
Expand Down

0 comments on commit 5348148

Please sign in to comment.