class SimpleJSONAPIClient::Redirection::FetchAll
Attributes
base_opts[R]
operation[R]
Public Class Methods
new(base_opts, &operation)
click to toggle source
# File lib/simple_jsonapi_client/redirection/fetch_all.rb, line 10 def initialize(base_opts, &operation) @base_opts = base_opts @operation = operation end
Private Instance Methods
current_opts()
click to toggle source
# File lib/simple_jsonapi_client/redirection/fetch_all.rb, line 40 def current_opts @current_opts ||= base_opts.dup end
fetch_internal_object()
click to toggle source
# File lib/simple_jsonapi_client/redirection/fetch_all.rb, line 22 def fetch_internal_object internal_enumerator.to_a end
internal_enumerator()
click to toggle source
# File lib/simple_jsonapi_client/redirection/fetch_all.rb, line 26 def internal_enumerator @internal_enumerator ||= Enumerator.new do |yielder| loop do current_response = operation.call(current_opts) current_response['data'].each do |record| yielder << record end break unless (next_link = Utils.hash_dig(current_response, 'links', 'next')) current_opts.merge!(url_opts: {}, url: next_link) current_opts.delete(:page_opts) end end end
pseudo_inspect()
click to toggle source
# File lib/simple_jsonapi_client/redirection/fetch_all.rb, line 18 def pseudo_inspect internal_enumerator.inspect end