Only call ::Mongoid::IdentityMap.clear if ::Mongoid::IdentityMap is defined.