Class: Hexabat::PageRequestBuilder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hexabat/page_request_builder.rb

Direct Known Subclasses

TokenAuthorized, Unauthorized

Constant Summary collapse

MAX_PAGE_SIZE =
100

Instance Method Summary collapse

Constructor Details

#initialize(repository, response_processor) ⇒ Base

Returns a new instance of Base.



21
22
23
24
25
# File 'lib/hexabat/page_request_builder.rb', line 21

def initialize(repository, response_processor)
  @repository = repository
  @response_processor = response_processor
  EM::HttpRequest.use(EM::Middleware::JSONResponse)
end

Instance Method Details

#endpointObject



35
36
37
# File 'lib/hexabat/page_request_builder.rb', line 35

def endpoint
  "https://api.github.com/repos/#{@repository}/issues"
end

#for(params, &page_callback) ⇒ Object



27
28
29
# File 'lib/hexabat/page_request_builder.rb', line 27

def for(params, &page_callback)
  build_request(query_from params).callback &page_retrieved(page_callback)
end

#page_retrieved(page_callback = nil) ⇒ Object



31
32
33
# File 'lib/hexabat/page_request_builder.rb', line 31

def page_retrieved(page_callback = nil)
  ->(http) { @response_processor.process(http, &page_callback) }
end