Module | Mongoid::Extensions::ObjectId::Conversions |
In: |
lib/mongoid/extensions/object_id/conversions.rb
|
Provides conversions to and from BSON::ObjectIds and Strings, Arrays, and Hashes.
Convert the supplied arguments to object ids based on the class settings.
@todo Durran: This method can be refactored.
@example Convert a string to an object id
BSON::ObjectId.convert(Person, "4c52c439931a90ab29000003")
@example Convert an array of strings to object ids.
BSON::ObjectId.convert(Person, [ "4c52c439931a90ab29000003" ])
@example Convert a hash of id strings to object ids.
BSON::ObjectId.convert(Person, { :_id => "4c52c439931a90ab29000003" })
@param [ Class ] klass The class to convert the ids for. @param [ Object, Array, Hash ] args The object to convert.
@raise BSON::InvalidObjectId If using object ids and passed bad
strings.
@return [ BSON::ObjectId, Array, Hash ] The converted object ids.
@since 2.0.0.rc.7