Class: Yes::Core::DataEncryptor
- Inherits:
-
Object
- Object
- Yes::Core::DataEncryptor
- Defined in:
- lib/yes/core/data_encryptor.rb
Overview
Encrypts event data attributes using a key from the key repository.
Instance Attribute Summary collapse
-
#encrypted_data ⇒ Hash
readonly
The encrypted data.
-
#encryption_metadata ⇒ Hash
readonly
The encryption metadata (key, iv, attributes).
Instance Method Summary collapse
-
#call ⇒ Hash
Encrypts the data attributes specified in the schema.
Instance Attribute Details
#encrypted_data ⇒ Hash (readonly)
Returns the encrypted data.
14 15 16 |
# File 'lib/yes/core/data_encryptor.rb', line 14 def encrypted_data @encrypted_data end |
#encryption_metadata ⇒ Hash (readonly)
Returns the encryption metadata (key, iv, attributes).
17 18 19 |
# File 'lib/yes/core/data_encryptor.rb', line 17 def @encryption_metadata end |
Instance Method Details
#call ⇒ Hash
Encrypts the data attributes specified in the schema.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yes/core/data_encryptor.rb', line 22 def call return encrypted_data if .empty? key_id = [:key] res = key_repository.find(key_id) res = key_repository.create(key_id) if res.failure? key = res.value! [:iv] = key.attributes[:iv] encrypt_attributes( key:, data: encrypted_data, attributes: [:attributes].map(&:to_s) ) end |