Skip to content

Commit

Permalink
Add compatibility with Grape >= 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fotos committed Dec 7, 2018
1 parent cfd0946 commit d9bab83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/api-pagination/hooks.rb
@@ -1,7 +1,14 @@
begin; require 'grape'; rescue LoadError; end
if defined?(Grape::API)
require 'grape/pagination'
Grape::API.send(:include, Grape::Pagination)

klass = if Grape::VERSION >= '1.2.0' || defined?(Grape::API::Instance)
Grape::API::Instance
else
Grape::API
end

klass.send(:include, Grape::Pagination)
end

begin; require 'pagy'; rescue LoadError; end
Expand Down
2 changes: 2 additions & 0 deletions spec/grape_spec.rb
Expand Up @@ -5,6 +5,8 @@
require 'support/shared_examples/last_page'

describe NumbersAPI do
it { is_expected.to be_kind_of(Grape::Pagination) }

describe 'GET #index' do
let(:link) { last_response.headers['Link'] }
let(:links) { link.split(', ') }
Expand Down

0 comments on commit d9bab83

Please sign in to comment.