Class: RailsPaginate::Renderers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_paginate/renderers/base.rb

Overview

base method

Direct Known Subclasses

HtmlDefault

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, collection, pager, options = {}) ⇒ Base

setup rails_paginate collection

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
# 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

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



4
5
6
# File 'lib/rails_paginate/renderers/base.rb', line 4

def collection
  @collection
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/rails_paginate/renderers/base.rb', line 4

def options
  @options
end

#pagerObject (readonly)

Returns the value of attribute pager.



4
5
6
# File 'lib/rails_paginate/renderers/base.rb', line 4

def pager
  @pager
end

#viewObject (readonly)

Returns the value of attribute view.



4
5
6
# File 'lib/rails_paginate/renderers/base.rb', line 4

def view
  @view
end

Instance Method Details

#renderObject

abstrack renderer

Raises:

  • (StandardError)


23
24
25
# File 'lib/rails_paginate/renderers/base.rb', line 23

def render
  raise StandardError, "render is not implemented"
end

#url_for_page(page) ⇒ Object

build url



18
19
20
# 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}))
end