lib/recurly/pager.rb in recurly-3.2.0 vs lib/recurly/pager.rb in recurly-3.2.1
- old
+ new
@@ -4,11 +4,11 @@
attr_reader :data, :next
def initialize(client:, path:, options: {})
@client = client
@path = path
- @options = options
+ @options = map_array_params(options)
@next = build_path(@path, @options)
end
# Enumerates each "page" from the server.
# This method yields a given block with the array of items
@@ -109,9 +109,19 @@
def build_path(path, options)
if options.empty?
path
else
"#{path}?#{URI.encode_www_form(options)}"
+ end
+ end
+
+ # Converts array parameters to CSV strings to maintain consistency with
+ # how the server expects the request to be formatted while providing the
+ # developer with an array type to maintain developer happiness!
+ def map_array_params(params)
+ @options = params.map do |key, param|
+ new_param = param.is_a?(Array) ? param.join(",") : param
+ [key, new_param]
end
end
end
end