1
0
Fork 0
mirror of https://github.com/kaminari/kaminari.git synced 2022-11-09 13:44:37 -05:00

kwargsify Paginator#initialize for API explicitness and code readability

This commit is contained in:
Akira Matsuda 2016-11-23 09:16:04 +09:00
parent 721654ca75
commit 4da42bd0bd

View file

@ -6,13 +6,13 @@ module Kaminari
module Helpers
# The main container tag
class Paginator < Tag
def initialize(template, options) #:nodoc:
def initialize(template, window: nil, outer_window: nil, left: nil, right: nil, inner_window: nil, **options) #:nodoc:
@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[:window] = window || inner_window || Kaminari.config.window
outer_window = outer_window || Kaminari.config.outer_window
h[:left] = left || Kaminari.config.left
h[:left] = outer_window if h[:left] == 0
h[:right] = options.delete(:right) || Kaminari.config.right
h[:right] = right || Kaminari.config.right
h[:right] = outer_window if h[:right] == 0
end
@template, @options = template, options