class RailsPaginate::Renderers::Base
base method
Attributes
collection[R]
options[R]
pager[R]
view[R]
Public Class Methods
new(view, collection, pager, options = {})
click to toggle source
setup rails_paginate collection
# File lib/rails_paginate/renderers/base.rb, line 7 def initialize(view, collection, pager, options = {}) raise ArgumentError, "first argument must be a RailsPaginate::Collection" unless collection.is_a? RailsPaginate::Collection raise ArgumentError, "second argument must be a Hash" unless options.is_a? Hash raise ArgumentError, "third argument must be an instance of RailsPaginate::Pagers::Base" unless pager.is_a? RailsPaginate::Pagers::Base @options = options @collection = collection @view = view @pager = pager end
Public Instance Methods
render()
click to toggle source
abstrack renderer
# File lib/rails_paginate/renderers/base.rb, line 23 def render raise StandardError, "render is not implemented" end
url_for_page(page)
click to toggle source
build url
# File lib/rails_paginate/renderers/base.rb, line 18 def url_for_page(page) view.url_for(view.default_url_options.merge({page_param.to_sym => page}).merge(options[:params] || {})) end
Protected Instance Methods
content_tag(*args, &block)
click to toggle source
map to view helper
# File lib/rails_paginate/renderers/base.rb, line 52 def content_tag(*args, &block) view.content_tag(*args, &block) end
current_page()
click to toggle source
helper
# File lib/rails_paginate/renderers/base.rb, line 47 def current_page collection.current_page end
link_to(*args, &block)
click to toggle source
map to view helper
# File lib/rails_paginate/renderers/base.rb, line 57 def link_to(*args, &block) view.link_to(*args, &block) end
link_to_page(page, key, link_options = {})
click to toggle source
link to page with i18n support
# File lib/rails_paginate/renderers/base.rb, line 30 def link_to_page(page, key, link_options = {}) css_class = "#{link_options[:class]} #{page == current_page ? 'current' : ''}" if key.nil? content_tag :span, "..", :class => "spacer" elsif page.nil? content_tag :span, t(key), :class => "#{css_class} unavailable" else link_to t(key, :page => page), url_for_page(page), :class => css_class, :alt => view.strip_tags(t(key, :page => page)), :remote => options[:remote], :method => options[:method] end end
page_param()
click to toggle source
# File lib/rails_paginate/renderers/base.rb, line 42 def page_param options[:page_param] || RailsPaginate.page_param end
t(*args)
click to toggle source
map to view helper
# File lib/rails_paginate/renderers/base.rb, line 62 def t(*args) view.t(*args) end