Refactoring collection wrapper

parent 2c92cc52
module Github
class Collection
def initialize(url)
@url = url
end
def fetch(query = {})
return [] if @url.blank?
def fetch(url, query = {})
return [] if url.blank?
Enumerator.new do |yielder|
loop do
response = client.get(@url, query)
response = client.get(url, query)
response.body.each { |item| yielder << item }
raise StopIteration unless response.rels.key?(:next)
@url = response.rels[:next]
url = response.rels[:next]
end
end.lazy
end
......
......@@ -5,7 +5,7 @@ module Github
end
def fetch
Collection.new(repos_url).fetch
Collection.new.fetch(repos_url)
end
private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment