Class: Hashematics::Id

Inherits:
Key
  • Object
show all
Defined in:
lib/hashematics/id.rb

Overview

An ID is just like a Key except its value is digested (hashed). The main rationale for this is ID’s also contains user data, which could be unbound data, which could potentially consume lots of memory. To limit this, we digest it.

Instance Attribute Summary

Attributes inherited from Key

#parts, #value

Class Method Summary collapse

Methods inherited from Key

#==, #eql?, get, #hash, #initialize

Constructor Details

This class inherits a constructor from Hashematics::Key

Class Method Details

.digest(val = '') ⇒ Object

This method is class-level to expose the underlying hashing algorithm used.



17
18
19
20
# File 'lib/hashematics/id.rb', line 17

def digest(val = '')
  # MD5 was chosen for its speed, it was not chosen for security.
  Digest::MD5.hexdigest(val)
end