Skip to content

Commit

Permalink
Now kaminari supports grape gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsliwa committed Mar 13, 2012
1 parent 118927a commit be46fb7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.gem
.bundle
.idea
Gemfile.lock
pkg/*

Expand Down
9 changes: 9 additions & 0 deletions lib/kaminari.rb
Expand Up @@ -31,6 +31,9 @@ def self.show_warning
when Sinatra/Padrino:
gem 'kaminari', :require => 'kaminari/sinatra'
when Grape:
gem 'kaminari', :require => 'kaminari/grape'
EOC
end

Expand All @@ -51,6 +54,8 @@ def self.hook!
require 'kaminari/engine'
elsif sinatra?
require 'kaminari/sinatra'
elsif grape?
require 'kaminari/grape'
else
Kaminari::Hooks.init!
end
Expand All @@ -68,6 +73,10 @@ def self.rails?
def self.sinatra?
defined?(::Sinatra)
end

def self.grape?
defined?(::Grape)
end
end

Kaminari.load!
10 changes: 10 additions & 0 deletions lib/kaminari/grape.rb
@@ -0,0 +1,10 @@
begin
require 'grape'
rescue LoadError
raise LoadError, "couldn't load `grape`, check out if appropriately bundled grape gem?"
end

require 'kaminari'

Kaminari::Hooks.init!

0 comments on commit be46fb7

Please sign in to comment.