lib/loquor/api_calls/index.rb in loquor-0.0.2 vs lib/loquor/api_calls/index.rb in loquor-0.1.0
- old
+ new
@@ -19,9 +19,21 @@
# transparently acts as an Array.
def method_missing(name, *args, &block)
results.send(name, *args, &block)
end
+ def find_each
+ page = 1
+ results = []
+ begin
+ results = Loquor.get("#{generate_url}&page=#{page}&per=#{per}")
+ results.each do |result|
+ yield result
+ end
+ page += 1
+ end while(results.size == per)
+ end
+
private
def results
if @results.nil?
@results = Loquor.get(generate_url)