lib/kaminari/helpers/paginator.rb in kaminari-0.15.0 vs lib/kaminari/helpers/paginator.rb in kaminari-0.15.1

- old
+ new

@@ -10,24 +10,27 @@ class Paginator < Tag # so that this instance can actually "render" include ::ActionView::Context def initialize(template, options) #:nodoc: + #FIXME for compatibility. remove num_pages at some time in the future + options[:total_pages] ||= options[:num_pages] + options[:num_pages] ||= options[:total_pages] + @window_options = {}.tap do |h| h[:window] = options.delete(:window) || options.delete(:inner_window) || Kaminari.config.window outer_window = options.delete(:outer_window) || Kaminari.config.outer_window h[:left] = options.delete(:left) || Kaminari.config.left h[:left] = outer_window if h[:left] == 0 h[:right] = options.delete(:right) || Kaminari.config.right h[:right] = outer_window if h[:right] == 0 end @template, @options = template, options @theme = @options[:theme] ? "#{@options[:theme]}/" : '' - @options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil - #FIXME for compatibility. remove num_pages at some time in the future - @options[:total_pages] ||= @options[:num_pages] - @options[:num_pages] ||= @options[:total_pages] + @window_options.merge! @options + @window_options[:current_page] = @options[:current_page] = PageProxy.new(@window_options, @options[:current_page], nil) + @last = nil # initialize the output_buffer for Context @output_buffer = ActionView::OutputBuffer.new end @@ -44,12 +47,12 @@ # * pages inside the inner window plus one on the left plus one on the right for showing the gap tags # * pages inside the right outer window plus one for showing the gap tag def each_relevant_page return to_enum(:each_relevant_page) unless block_given? - relevant_pages(@window_options.merge(@options)).each do |i| - yield PageProxy.new(@window_options.merge(@options), i, @last) + relevant_pages(@window_options).each do |i| + yield PageProxy.new(@window_options, i, @last) end end alias each_page each_relevant_page def relevant_pages(options) @@ -92,15 +95,15 @@ end end end subscriber.render_without_logging = true - ret = super @window_options.merge(@options).merge :paginator => self + ret = super @window_options.merge :paginator => self subscriber.render_without_logging = false ret else - super @window_options.merge(@options).merge :paginator => self + super @window_options.merge :paginator => self end end # Wraps a "page number" and provides some utility methods class PageProxy