lib/shipit/paginator.rb in shipit-engine-0.31.0 vs lib/shipit/paginator.rb in shipit-engine-0.32.0
- old
+ new
@@ -1,8 +1,9 @@
+# frozen_string_literal: true
module Shipit
class Paginator
- def initialize(resources, controller, order: {id: :desc}, max_page_size: 100, default_page_size: 30)
+ def initialize(resources, controller, order: { id: :desc }, max_page_size: 100, default_page_size: 30)
@order = order
@controller = controller
@since = controller.params[:since].presence
page_size = controller.params[:page_size].presence || default_page_size
@page_size = [page_size.to_i, max_page_size].min
@@ -13,10 +14,10 @@
def to_a
@resources[0, @page_size]
end
def links
- links = {first: link_to(since: nil, page_size: (page_size if page_size != @default_page_size))}
+ links = { first: link_to(since: nil, page_size: (page_size if page_size != @default_page_size)) }
links[:next] = link_to(since: to_a.last.id) unless last_page?
links
end
private