diff --git a/lib/bson/types/object_id.rb b/lib/bson/types/object_id.rb index 50968e3..7b97699 100644 --- a/lib/bson/types/object_id.rb +++ b/lib/bson/types/object_id.rb @@ -53,10 +53,7 @@ module BSON # # @return [Boolean] def self.legal?(str) - len = 24 - str =~ /([0-9a-f]+)/i - match = $1 - str && str.length == len && match == str + str =~ /^[0-9a-f]{24}$/i ? true : false end # Create an object id from the given time. This is useful for doing range