Class: Wee::Md5IdGenerator
- Inherits:
-
IdGenerator
- Object
- IdGenerator
- Wee::Md5IdGenerator
- Defined in:
- lib/wee/idgen/md5.rb
Instance Method Summary collapse
-
#initialize(salt = 'wee') ⇒ Md5IdGenerator
constructor
A new instance of Md5IdGenerator.
- #next ⇒ Object
Constructor Details
#initialize(salt = 'wee') ⇒ Md5IdGenerator
Returns a new instance of Md5IdGenerator.
7 8 9 |
# File 'lib/wee/idgen/md5.rb', line 7 def initialize(salt='wee') @salt = salt end |
Instance Method Details
#next ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wee/idgen/md5.rb', line 11 def next now = Time.now md5 = Digest::MD5.new md5.update(now.to_s) md5.update(now.usec.to_s) md5.update(rand(0).to_s) md5.update($$.to_s) md5.update(@salt.to_s) md5.hexdigest end |