Class: Yes::Core::EncryptionMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/encryption_metadata.rb

Overview

Extracts encryption metadata from a command/event’s encryption schema.

Examples:

 = EncryptionMetadata.new(data: event.data, schema: event.class.encryption_schema)
.call # => { key: 'user-123', attributes: [:email, :phone] }

Instance Method Summary collapse

Instance Method Details

#callHash

Returns the encryption metadata (key, attributes) or empty hash.

Returns:

  • (Hash)

    the encryption metadata (key, attributes) or empty hash



12
13
14
15
16
17
18
19
# File 'lib/yes/core/encryption_metadata.rb', line 12

def call
  return {} unless schema

  {
    key: schema[:key].call(data),
    attributes: schema[:attributes].map(&:to_sym)
  }
end