Class: EventStoreClient::DataEncryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/event_store_client/data_encryptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#encrypted_dataObject (readonly)

Returns the value of attribute encrypted_data.



21
22
23
# File 'lib/event_store_client/data_encryptor.rb', line 21

def encrypted_data
  @encrypted_data
end

#encryption_metadataObject (readonly)

Returns the value of attribute encryption_metadata.



21
22
23
# File 'lib/event_store_client/data_encryptor.rb', line 21

def 
  @encryption_metadata
end

Instance Method Details

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/event_store_client/data_encryptor.rb', line 5

def call
  return encrypted_data if .empty?

  key_id = [:key]
  res = key_repository.find(key_id)
  res = res.failure? ? key_repository.create(key_id) : res
  key = res.value!

  [:iv] = key.attributes[:iv]
  encrypt_attributes(
    key: key,
    data: encrypted_data,
    attributes: [:attributes].map(&:to_s)
  )
end