Class: StackMaster::PagedResponseAccumulator
- Inherits:
-
Object
- Object
- StackMaster::PagedResponseAccumulator
- Defined in:
- lib/stack_master/paged_response_accumulator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(cf, method, arguments, accumulator_method) ⇒ PagedResponseAccumulator
constructor
A new instance of PagedResponseAccumulator.
Constructor Details
#initialize(cf, method, arguments, accumulator_method) ⇒ PagedResponseAccumulator
Returns a new instance of PagedResponseAccumulator.
7 8 9 10 11 12 |
# File 'lib/stack_master/paged_response_accumulator.rb', line 7 def initialize(cf, method, arguments, accumulator_method) @cf = cf @method = method @arguments = arguments @accumulator_method = accumulator_method end |
Class Method Details
.call(*args) ⇒ Object
3 4 5 |
# File 'lib/stack_master/paged_response_accumulator.rb', line 3 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stack_master/paged_response_accumulator.rb', line 14 def call book = [] next_token = nil first_response = nil begin response = @cf.public_send(@method, @arguments.merge(next_token: next_token)) first_response = response if first_response.nil? next_token = response.next_token book += response.public_send(@accumulator_method) end while !next_token.nil? first_response.send("#{@accumulator_method}=", book.reverse) first_response.send(:next_token=, book.reverse) first_response end |