Class: RoutingFilter::Pagination
- Defined in:
- lib/routing_filter/filters/pagination.rb
Constant Summary collapse
- PAGINATION_SEGMENT =
%r(/page/([\d]+)/?$)
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
Methods inherited from Filter
#initialize, #run, #run_reverse
Constructor Details
This class inherits a constructor from RoutingFilter::Filter
Instance Method Details
#around_generate(params, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/routing_filter/filters/pagination.rb', line 34 def around_generate(params, &block) page = params.delete(:page) yield.tap do |result| append_segment!(result, "page/#{page}") if append_page?(page) end end |
#around_recognize(path, env, &block) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/routing_filter/filters/pagination.rb', line 27 def around_recognize(path, env, &block) page = extract_segment!(PAGINATION_SEGMENT, path) yield(path, env).tap do |params| params[:page] = page.to_i if page end end |