Skip to content

Commit 7384b51

Browse files
author
Samir Ali-Cherif
committed
Ajouter le support de pagy 9
1 parent d173212 commit 7384b51

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/api-pagination.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def paginate_with_pagy(collection, options)
5050
if Pagy::DEFAULT[:max_per_page] && options[:per_page] > Pagy::DEFAULT[:max_per_page]
5151
options[:per_page] = Pagy::DEFAULT[:max_per_page]
5252
elsif options[:per_page] <= 0
53-
options[:per_page] = Pagy::DEFAULT[:items]
53+
options[:per_page] = Pagy::DEFAULT[:limit]
5454
end
5555

5656
pagy = pagy_from(collection, options)
5757
collection = if collection.respond_to?(:offset) && collection.respond_to?(:limit)
58-
collection.offset(pagy.offset).limit(pagy.items)
58+
collection.offset(pagy.offset).limit(pagy.limit)
5959
else
60-
collection[pagy.offset, pagy.items]
60+
collection[pagy.offset, pagy.limit]
6161
end
6262

6363
return [collection, pagy]
@@ -70,7 +70,7 @@ def pagy_from(collection, options)
7070
count = collection.is_a?(Array) ? collection.count : collection.count(:all)
7171
end
7272

73-
Pagy.new(count: count, items: options[:per_page], page: options[:page])
73+
Pagy.new(count: count, limit: options[:per_page], page: options[:page])
7474
end
7575

7676
def pagy_pages_from(pagy)

spec/rails_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class Fixnum
286286

287287
expect(response.header['Per-Page']).to eq(
288288
case ApiPagination.config.paginator
289-
when :pagy then Pagy::DEFAULT[:items].to_s
289+
when :pagy then Pagy::DEFAULT[:limit].to_s
290290
when :kaminari then Kaminari.config.default_per_page.to_s
291291
when :will_paginate then WillPaginate.per_page.to_s
292292
end
@@ -301,7 +301,7 @@ class Fixnum
301301

302302
expect(response.header['Per-Page']).to eq(
303303
case ApiPagination.config.paginator
304-
when :pagy then Pagy::DEFAULT[:items].to_s
304+
when :pagy then Pagy::DEFAULT[:limit].to_s
305305
when :kaminari then Kaminari.config.default_per_page.to_s
306306
when :will_paginate then WillPaginate.per_page.to_s
307307
end

0 commit comments

Comments
 (0)