Class: Kaminari::Helpers::Paginator

Inherits:
Tag
  • Object
show all
Includes:
Renderable
Defined in:
lib/kaminari/helpers/tags.rb

Overview

The container tag

Defined Under Namespace

Classes: PageProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renderable

included

Constructor Details

#initialize(template, window_options) ⇒ Paginator

:nodoc:



74
75
76
77
78
# File 'lib/kaminari/helpers/tags.rb', line 74

def initialize(template, window_options) #:nodoc:
  @template, @options = template, window_options.reverse_merge(template.options)
  # so that this instance can actually "render". Black magic?
  @output_buffer = ActionView::OutputBuffer.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



72
73
74
# File 'lib/kaminari/helpers/tags.rb', line 72

def options
  @options
end

Instance Method Details

#each_pageObject

enumerate each page providing PageProxy object as the block parameter



87
88
89
90
91
92
# File 'lib/kaminari/helpers/tags.rb', line 87

def each_page
  1.upto(@options[:num_pages]) do |i|
    @page = i
    yield PageProxy.new(options, i, @last)
  end
end

#render(&block) ⇒ Object

render given block as a view template



81
82
83
84
# File 'lib/kaminari/helpers/tags.rb', line 81

def render(&block)
  instance_eval &block if @options[:num_pages] > 1
  @output_buffer
end

#to_s(window_options = {}) ⇒ Object

:nodoc:



110
111
112
# File 'lib/kaminari/helpers/tags.rb', line 110

def to_s(window_options = {}) #:nodoc:
  super window_options.merge :paginator => self
end