module Aws::PageableResponse::Extension
The actual decorator module implementation. It is in a distinct module so that it can be used to extend objects without busting Ruby's constant cache. object.extend(mod) bust the constant cache only if `mod` contains constants of its own. @api private
Attributes
pager[RW]
Public Instance Methods
each() { |response| ... }
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 181 def each(&block) return enum_for(:each_page) unless block_given? response = self yield(response) until response.last_page? response = response.next_page yield(response) end end
Also aliased as: each_page
last_page?()
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 162 def last_page? if @last_page.nil? @last_page = !@pager.truncated?(self) end @last_page end
next_page(params = {})
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 173 def next_page(params = {}) if last_page? raise LastPageError.new(self) else next_response(params) end end
next_page?()
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 169 def next_page? !last_page? end
Private Instance Methods
next_page_params(params)
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 200 def next_page_params(params) # Remove all previous tokens from original params # Sometimes a token can be nil and merge would not include it. tokens = @pager.tokens.values.map(&:to_sym) params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) } params_without_tokens.merge!(@pager.next_tokens(self).merge(params)) params_without_tokens end
next_response(params)
click to toggle source
# File lib/aws-sdk-core/pageable_response.rb, line 194 def next_response(params) params = next_page_params(params) request = context.client.build_request(context.operation_name, params) request.send_request end