Class: RoutingFilter::Pagination

Inherits:
Base
  • Object
show all
Defined in:
lib/routing_filter/pagination.rb

Instance Attribute Summary

Attributes inherited from Base

#chain, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #predecessor, #run, #run_reverse, #successor

Constructor Details

This class inherits a constructor from RoutingFilter::Base

Instance Method Details

#around_generate(*args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/routing_filter/pagination.rb', line 12

def around_generate(*args, &block)
  page = args.extract_options!.delete(:page)
  returning yield do |result|
    if page && page != 1
      url = result.is_a?(Array) ? result.first : result
      append_page!(url, page)
    end
  end
end

#around_recognize(path, env, &block) ⇒ Object



5
6
7
8
9
10
# File 'lib/routing_filter/pagination.rb', line 5

def around_recognize(path, env, &block)
  page = extract_page!(path)
  returning yield(path, env) do |params|
    params[:page] = page.to_i if page
  end
end