Created
December 2, 2011 22:49
-
-
Save ahoward/1425207 to your computer and use it in GitHub Desktop.
just gimme a damn uuid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'ffi-uuid' => proc{|*args| FFI::UUID.generate_time.to_s}, | |
'uuid' => proc{|*args| UUID.generate.to_s}, | |
'uuidtools' => proc{|*args| UUIDTools::UUID.timestamp_create.to_s} | |
}.each do |lib, implementation| | |
begin | |
require(lib) | |
define_method(:uuid, &implementation) | |
break | |
rescue LoadError | |
nil | |
end | |
end | |
abort 'no suitable uuid generation library detected' unless method_defined?(:uuid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment