Class: Kaminari::Helpers::Tag
- Inherits:
-
Object
- Object
- Kaminari::Helpers::Tag
- Defined in:
- lib/bhf/pagination.rb
Instance Method Summary collapse
-
#initialize(template, options = {}) ⇒ Tag
constructor
:nodoc:.
- #page_url_for(page) ⇒ Object
-
#to_s(locals = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(template, options = {}) ⇒ Tag
:nodoc:
4 5 6 7 8 9 |
# File 'lib/bhf/pagination.rb', line 4 def initialize(template, = {}) #:nodoc: @template, @options = template, .dup @param_name = @options.delete(:param_name) @theme = @options[:theme] ? "#{@options.delete(:theme)}/" : '' @params = @options[:params] ? template.params.merge(@options.delete :params) : template.params end |
Instance Method Details
#page_url_for(page) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/bhf/pagination.rb', line 15 def page_url_for(page) if @param_name.is_a?(Array) @params[@param_name[0]] = (@params[@param_name[0]] || {}).merge(@param_name[1] => (page <= 1 ? nil : page)) return @template.url_for @params end @template.url_for @params.merge(@param_name => (page <= 1 ? nil : page)) end |
#to_s(locals = {}) ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/bhf/pagination.rb', line 11 def to_s(locals = {}) #:nodoc: @template.render partial: "kaminari/#{@theme}#{self.class.name.demodulize.underscore}", locals: @options.merge(locals) end |