api-pagination
api-pagination copied to clipboard
Allow configuration overrides from request options
In my own projects I was required to change the configuration on request basis. For example you have /api/v1
which uses a different header name for the page than /api/v2
. Using a configuration block in a before action like
before do
ApiPagination.configure do |config|
config.include_total = false
end
end
is not thread safe and will thus not work on servers like puma
. Therefore I've added the option to override configs through the paginate options hash. In theory you can even change the paginator between requests.
Hope you like the idea!