Class: ActionSet::Helpers::Paginator
- Inherits:
-
Object
- Object
- ActionSet::Helpers::Paginator
- Defined in:
- lib/action_set/helpers/paginator.rb
Defined Under Namespace
Classes: PageInterface
Instance Method Summary collapse
-
#initialize(template) ⇒ Paginator
constructor
A new instance of Paginator.
- #render(set) ⇒ Object
Constructor Details
#initialize(template) ⇒ Paginator
Returns a new instance of Paginator.
6 7 8 9 |
# File 'lib/action_set/helpers/paginator.rb', line 6 def initialize(template) @template = template @info = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
delegates view helper methods to @template
110 111 112 |
# File 'lib/action_set/helpers/paginator.rb', line 110 def method_missing(name, *args, &block) @template.respond_to?(name) ? @template.send(name, *args, &block) : super end |
Instance Method Details
#render(set) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/action_set/helpers/paginator.rb', line 11 def render(set) @info = info_for_set(set) content_tag(:ul, class: 'pagination') do safe_join([ link_to_first_page, link_to_prev_page, link_to_prev_gap, safe_join(relevant_page_numbers.map do |num| page = PageInterface.new(num, @info) link = link_to(page, page_link_url(page), rel: page.rel) content_tag(:li, link, class: ['page', (page.current? ? 'active' : nil)].compact) end), link_to_next_gap, link_to_next_page, link_to_last_page ].compact) end end |