Fix build error caused by BSON namespace change in Mongoid 4.0. Closes #1764