diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-04-12 22:43:38 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-04-24 16:17:52 -0300 |
commit | 8538066e00d8bda542f219fb03d104f8364760bd (patch) | |
tree | 681b32b4589254424f2e974f400381638a6a7df7 /lib/github | |
parent | 2c92cc52d74d41663e96a0a3eabf268db3f68947 (diff) | |
download | gitlab-ce-8538066e00d8bda542f219fb03d104f8364760bd.tar.gz |
Refactoring collection wrapper
Diffstat (limited to 'lib/github')
-rw-r--r-- | lib/github/collection.rb | 12 | ||||
-rw-r--r-- | lib/github/repositories.rb | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/github/collection.rb b/lib/github/collection.rb index bbca12a1c84..1b0c00928c5 100644 --- a/lib/github/collection.rb +++ b/lib/github/collection.rb @@ -1,18 +1,14 @@ 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 diff --git a/lib/github/repositories.rb b/lib/github/repositories.rb index 42342471102..b6a03173673 100644 --- a/lib/github/repositories.rb +++ b/lib/github/repositories.rb @@ -5,7 +5,7 @@ module Github end def fetch - Collection.new(repos_url).fetch + Collection.new.fetch(repos_url) end private |