Class: Bkblz::V1::PaginatedResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/bkblz/v1/response.rb

Constant Summary collapse

NoMorePagesError =
Class.new Bkblz::BaseError

Constants inherited from Response

Response::MissingResponseError

Class Attribute Summary collapse

Attributes inherited from Response

#http_response, #parsed_body

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#[], #initialize, #parse, response_accessor, response_accessors, response_model, #to_model

Constructor Details

This class inherits a constructor from Bkblz::V1::Response

Class Attribute Details

.pagination_fieldsObject (readonly)

Returns the value of attribute pagination_fields.



90
91
92
# File 'lib/bkblz/v1/response.rb', line 90

def pagination_fields
  @pagination_fields
end

Class Method Details

.pagination_accessors(*pagination_fields) ⇒ Object



91
92
93
94
95
96
# File 'lib/bkblz/v1/response.rb', line 91

def pagination_accessors(*pagination_fields)
  response_accessors *pagination_fields

  @pagination_fields ||= []
  @pagination_fields.concat pagination_fields
end

Instance Method Details

#has_more?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/bkblz/v1/response.rb', line 99

def has_more?
  self.class.pagination_fields.any? { |f| !self[f].nil? }
end

#next_request(limit = nil) ⇒ Object

Raises:



103
104
105
106
# File 'lib/bkblz/v1/response.rb', line 103

def next_request(limit=nil)
  raise NoMorePagesError unless has_more?
  build_next_request(limit)
end