class Rooftop::PaginationMiddleware
Public Instance Methods
on_complete(env)
click to toggle source
# File lib/rooftop/middleware/pagination_middleware.rb, line 3 def on_complete(env) @env = env pagination = { total_count: header("x-wp-total").to_i, total_pages: header("x-wp-totalpages").to_i, per_page: (header("x-wp-per-page").to_i || 10), page: header("x-wp-page").to_i || 1 } env[:body].merge!(pagination: pagination) end
Private Instance Methods
header(name)
click to toggle source
Returns a response header value.
@param [String] name of the header attribute @return [String] the response header value
# File lib/rooftop/middleware/pagination_middleware.rb, line 22 def header(name) @env.response_headers[name] end