Skip to content

Commit 4795c59

Browse files
authored
Merge pull request #117 from fotos/grape-1.2-compatibility
Add compatibility with Grape >= 1.2.0
2 parents cfd0946 + d9bab83 commit 4795c59

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/api-pagination/hooks.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
begin; require 'grape'; rescue LoadError; end
22
if defined?(Grape::API)
33
require 'grape/pagination'
4-
Grape::API.send(:include, Grape::Pagination)
4+
5+
klass = if Grape::VERSION >= '1.2.0' || defined?(Grape::API::Instance)
6+
Grape::API::Instance
7+
else
8+
Grape::API
9+
end
10+
11+
klass.send(:include, Grape::Pagination)
512
end
613

714
begin; require 'pagy'; rescue LoadError; end

spec/grape_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
require 'support/shared_examples/last_page'
66

77
describe NumbersAPI do
8+
it { is_expected.to be_kind_of(Grape::Pagination) }
9+
810
describe 'GET #index' do
911
let(:link) { last_response.headers['Link'] }
1012
let(:links) { link.split(', ') }

0 commit comments

Comments
 (0)