Module: Greenroom::Digest
- Defined in:
- lib/greenroom/digest.rb
Overview
Turns an observed value into a short, fixed-length digest for a sample event. Never carries the value itself, only evidence that two values did or did not match.
Class Method Summary collapse
-
.of(value) ⇒ Object
Value stability is the host's job, via Scientist's own
cleanblock -- this module only shortens whatever that block already produced.
Class Method Details
.of(value) ⇒ Object
Value stability is the host's job, via Scientist's own clean block --
this module only shortens whatever that block already produced. The
default #inspect can embed an object's memory address, so a host that
needs a digest to stay stable across runs must write a clean block
rather than rely on this method to normalize the value.
::Digest::SHA256, not SHA256: this module is itself named Digest,
so an unqualified Digest::SHA256 would resolve to
Greenroom::Digest::SHA256 (itself) under Ruby's lexical scoping,
rather than the standard library's ::Digest module.
22 23 24 25 26 |
# File 'lib/greenroom/digest.rb', line 22 def of(value) return nil if value.nil? ::Digest::SHA256.hexdigest(value.inspect) end |