From 0b577033efbcd8a9fa861edffc1a9896f3f790bd Mon Sep 17 00:00:00 2001 From: Velkitor Date: Wed, 25 Sep 2013 13:54:21 -0700 Subject: [PATCH] Ensure that Moped and Moped::BSON is defined before testing against Moped::BSON::ObjectID In my environment we had an issue where ap was causing sidekiq to blow up because apparently our moped is not eager loading Moped::BSON. Moped was present. --- lib/awesome_print/ext/mongoid.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/awesome_print/ext/mongoid.rb b/lib/awesome_print/ext/mongoid.rb index 7f8b8e0..ff81743 100644 --- a/lib/awesome_print/ext/mongoid.rb +++ b/lib/awesome_print/ext/mongoid.rb @@ -20,7 +20,7 @@ module AwesomePrint cast = :mongoid_class elsif object.class.ancestors.include?(::Mongoid::Document) cast = :mongoid_document - elsif (defined?(::BSON) && object.is_a?(::BSON::ObjectId)) || (defined?(::Moped) && object.is_a?(::Moped::BSON::ObjectId)) + elsif (defined?(::BSON) && object.is_a?(::BSON::ObjectId)) || (defined?(::Moped) && defined?(::Moped::BSON) && object.is_a?(::Moped::BSON::ObjectId)) cast = :mongoid_bson_id end end