Module: DigestGenerator
- Extended by:
- DigestGenerator
- Included in:
- DigestGenerator
- Defined in:
- lib/digest_generator.rb,
lib/digest_generator/version.rb
Overview
DigestGenerator
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- MASK_64BIT =
0x7FFFFFFFFFFFFFFF
- XXHASH_ALGO =
'xxHash'
- SUPPORTED_ALGORITHMS =
[XXHASH_ALGO].freeze
- VERSION =
'0.1.2'
Class Method Summary collapse
Instance Method Summary collapse
- #algorithm ⇒ Object
- #algorithm=(value) ⇒ Object
- #configure_default_algo ⇒ Object
- #digest_32bit(payload) ⇒ Object
-
#digest_63bit(payload) ⇒ Object
Hash 64 and mask bit 63 (0-63) to remove signedness to be compatible with postgress bigints.
- #digest_64bit(payload) ⇒ Object
Class Method Details
.included(base) ⇒ Object
43 44 45 |
# File 'lib/digest_generator.rb', line 43 def self.included(base) base.include(InstanceMethods) end |
Instance Method Details
#algorithm ⇒ Object
15 16 17 |
# File 'lib/digest_generator.rb', line 15 def algorithm @algorithm end |
#algorithm=(value) ⇒ Object
19 20 21 |
# File 'lib/digest_generator.rb', line 19 def algorithm=(value) @algorithm = value end |
#configure_default_algo ⇒ Object
23 24 25 |
# File 'lib/digest_generator.rb', line 23 def configure_default_algo self.algorithm = XXHASH_ALGO if algorithm.nil? || algorithm == '' end |
#digest_32bit(payload) ⇒ Object
33 34 35 36 |
# File 'lib/digest_generator.rb', line 33 def digest_32bit(payload) configure_default_algo send("#{algorithm.downcase}32_digest", payload) end |
#digest_63bit(payload) ⇒ Object
Hash 64 and mask bit 63 (0-63) to remove signedness to be compatible with postgress bigints
28 29 30 31 |
# File 'lib/digest_generator.rb', line 28 def digest_63bit(payload) configure_default_algo send("#{algorithm.downcase}63_digest", payload) end |
#digest_64bit(payload) ⇒ Object
38 39 40 41 |
# File 'lib/digest_generator.rb', line 38 def digest_64bit(payload) configure_default_algo send("#{algorithm.downcase}64_digest", payload) end |