Created
March 31, 2012 14:59
-
-
Save dblock/2265877 to your computer and use it in GitHub Desktop.
An iterator over all Google Analytics results with Garb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Garb | |
module Model | |
def all(profile, options = {}, &block) | |
limit = options.delete(:limit) | |
total = 0 | |
while ((rs = results(profile, options)) && rs.any?) | |
rs.each do |r| | |
yield r | |
total += 1 | |
break if limit and total >= limit | |
end | |
options[:offset] = total | |
end | |
self | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment