Module: Ace::PromptPrep::Atoms::ContentHasher

Defined in:
lib/ace/prompt_prep/atoms/content_hasher.rb

Overview

Generates SHA256 hash for content

Class Method Summary collapse

Class Method Details

.call(content:) ⇒ Hash

Generate hash for content

Parameters:

  • content (String, nil)

    Content to hash

Returns:

  • (Hash)

    Hash with :hash key



14
15
16
17
18
19
20
# File 'lib/ace/prompt_prep/atoms/content_hasher.rb', line 14

def self.call(content:)
  if content.nil? || content.empty?
    {hash: ""}
  else
    {hash: Digest::SHA256.hexdigest(content)}
  end
end