Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

require mongoid only when it is available

  • Loading branch information...
commit 46c00267d38ba7ca9f86bee00e5baaf3eea5f500 1 parent e01eb23
@flyerhzm authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/bullet.rb
View
12 lib/bullet.rb
@@ -12,10 +12,14 @@ module Bullet
autoload :ActiveRecord, 'bullet/active_record2'
autoload :ActionController, 'bullet/action_controller2'
end
- if Mongoid::VERSION =~ /\A2\.4/
- autoload :Mongoid, 'bullet/mongoid24'
- elsif Mongoid::VERSION =~ /\A3/
- autoload :Mongoid, 'bullet/mongoid3'
+ begin
+ require 'mongoid'
+ if Mongoid::VERSION =~ /\A2\.4/
+ autoload :Mongoid, 'bullet/mongoid24'
+ elsif Mongoid::VERSION =~ /\A3/
+ autoload :Mongoid, 'bullet/mongoid3'
+ end
+ rescue LoadError
end
autoload :Rack, 'bullet/rack'
autoload :BulletLogger, 'bullet/logger'
Please sign in to comment.
Something went wrong with that request. Please try again.