Skip to content

Commit 55fc4a0

Browse files
authored
Merge pull request #140 from buildrtech/support-pagy-v43
Support pagy v43
2 parents 5e98241 + 9a5811e commit 55fc4a0

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gemspec
77
# Without these, Bundler may override gemspec constraints and install incompatible versions
88
gem "kaminari", "~> 1.2", ">= 1.2.1", require: false
99
gem "will_paginate", "~> 3.3", ">= 3.3.1", require: false
10-
gem "pagy", ">= 9.4.0", "< 10.0.0", require: false
10+
gem "pagy", "~> 43.0", require: false
1111

1212
gem "sqlite3", require: false
1313
gem "sequel", "~> 5.49", require: false

api-pagination.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
1717
s.required_ruby_version = "> 2.7"
1818

1919
s.add_development_dependency "kaminari", "~> 1.2", ">= 1.2.1"
20-
s.add_development_dependency "pagy", ">= 9.4.0", "< 10.0.0"
20+
s.add_development_dependency "pagy", "~> 43.0"
2121
s.add_development_dependency "will_paginate", "~> 3.3", ">= 3.3.1"
2222

2323
s.add_development_dependency "rspec", "~> 3.10"

lib/api-pagination.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def total_from(collection)
4747
private
4848

4949
def paginate_with_pagy(collection, options)
50-
if Pagy::DEFAULT[:max_per_page] && options[:per_page] > Pagy::DEFAULT[:max_per_page]
51-
options[:per_page] = Pagy::DEFAULT[:max_per_page]
50+
if Pagy.options[:max_per_page] && options[:per_page] > Pagy.options[:max_per_page]
51+
options[:per_page] = Pagy.options[:max_per_page]
5252
elsif options[:per_page] <= 0
53-
options[:per_page] = Pagy::DEFAULT[:limit]
53+
options[:per_page] = Pagy.options[:limit]
5454
end
5555

5656
pagy = pagy_from(collection, options)
@@ -73,14 +73,14 @@ def pagy_from(collection, options)
7373
# Pagy 9.x requires keyword arguments
7474
# Use explicit keyword argument syntax to avoid Ruby version quirks
7575
pagy_options = {count: count, limit: options[:per_page], page: options[:page]}
76-
Pagy.new(**pagy_options)
76+
Pagy::Offset.new(**pagy_options)
7777
end
7878

7979
def pagy_pages_from(pagy)
8080
{}.tap do |pages|
8181
unless pagy.page == 1
8282
pages[:first] = 1
83-
pages[:prev] = pagy.prev
83+
pages[:prev] = pagy.previous
8484
end
8585

8686
unless pagy.page == pagy.pages

spec/rails_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class << Integer
285285

286286
expect(response.header["Per-Page"]).to eq(
287287
case ApiPagination.config.paginator
288-
when :pagy then Pagy::DEFAULT[:limit].to_s
288+
when :pagy then Pagy.options[:limit].to_s
289289
when :kaminari then Kaminari.config.default_per_page.to_s
290290
when :will_paginate then WillPaginate.per_page.to_s
291291
end
@@ -300,7 +300,7 @@ class << Integer
300300

301301
expect(response.header["Per-Page"]).to eq(
302302
case ApiPagination.config.paginator
303-
when :pagy then Pagy::DEFAULT[:limit].to_s
303+
when :pagy then Pagy.options[:limit].to_s
304304
when :kaminari then Kaminari.config.default_per_page.to_s
305305
when :will_paginate then WillPaginate.per_page.to_s
306306
end

0 commit comments

Comments
 (0)