From 5e81cf2f82f4c2bcfc287f1f81122ef0f79f264a Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Sat, 13 Mar 2010 15:24:05 -0500 Subject: [PATCH] simplify logic --- lib/bson/types/object_id.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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