Class: Sonar::Request::RequestIterator
- Inherits:
-
Object
- Object
- Sonar::Request::RequestIterator
- Includes:
- Sonar::Request
- Defined in:
- lib/sonar/request.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#params ⇒ Object
Returns the value of attribute params.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(url, connection, params = {}) ⇒ RequestIterator
constructor
A new instance of RequestIterator.
Methods included from Sonar::Request
#extract_params, #get, #post, #put, #request
Constructor Details
#initialize(url, connection, params = {}) ⇒ RequestIterator
Returns a new instance of RequestIterator.
43 44 45 46 47 |
# File 'lib/sonar/request.rb', line 43 def initialize(url, connection, params = {}) self.url = url self.connection = connection self.params = params end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
41 42 43 |
# File 'lib/sonar/request.rb', line 41 def connection @connection end |
#params ⇒ Object
Returns the value of attribute params.
41 42 43 |
# File 'lib/sonar/request.rb', line 41 def params @params end |
#url ⇒ Object
Returns the value of attribute url.
41 42 43 |
# File 'lib/sonar/request.rb', line 41 def url @url end |
Instance Method Details
#each ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sonar/request.rb', line 49 def each more = true records_rcvd = 0 while more && records_rcvd < params[:limit] # TODO: refactor to not pass around the connection params[:connection] = connection resp = get(url, params) params[:iterator_id] = resp.iterator_id records_rcvd += resp['collection'].size rescue 0 more = resp['more'] yield resp end params.delete(:iterator_id) end |