Reduce Hash creation

This commit is contained in:
Akira Matsuda 2013-11-24 01:04:11 +09:00
parent a5ebc7cc89
commit 8902c44b36
1 changed files with 7 additions and 5 deletions

View File

@ -26,7 +26,9 @@ module Kaminari
end end
@template, @options = template, options @template, @options = template, options
@theme = @options[:theme] ? "#{@options[:theme]}/" : '' @theme = @options[:theme] ? "#{@options[:theme]}/" : ''
@options[:current_page] = PageProxy.new @window_options.merge(@options), @options[:current_page], nil @window_options.merge! @options
@window_options[:current_page] = @options[:current_page] = PageProxy.new @window_options, @options[:current_page], nil
@last = nil @last = nil
# initialize the output_buffer for Context # initialize the output_buffer for Context
@output_buffer = ActionView::OutputBuffer.new @output_buffer = ActionView::OutputBuffer.new
@ -47,8 +49,8 @@ module Kaminari
def each_relevant_page def each_relevant_page
return to_enum(:each_relevant_page) unless block_given? return to_enum(:each_relevant_page) unless block_given?
relevant_pages(@window_options.merge(@options)).each do |i| relevant_pages(@window_options).each do |i|
yield PageProxy.new(@window_options.merge(@options), i, @last) yield PageProxy.new(@window_options, i, @last)
end end
end end
alias each_page each_relevant_page alias each_page each_relevant_page
@ -95,12 +97,12 @@ module Kaminari
end end
subscriber.render_without_logging = true 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 subscriber.render_without_logging = false
ret ret
else else
super @window_options.merge(@options).merge :paginator => self super @window_options.merge :paginator => self
end end
end end