10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/github_watched/api.rb', line 10
def list(end_point, options = {})
paginated = options.delete(:paginated)
klass = options.delete(:klass)
options[:params] ||= {}
options[:params][:per_page] ||= 100
Enumerator.new do |y|
begin
result = connection.raw_get(end_point, options)
raise "Unable to retrieve #{end_point}" unless result
result.parsed_response.each do |item|
item = klass.new(item, connection) if klass
y << item
end
options[:params][:page] = paginated && connection.(result., 'next')
end while options[:params][:page]
end
end
|