Class: DocVault::StoreDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_vault/store_document.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:, id:, bucket:, key:) ⇒ StoreDocument

Returns a new instance of StoreDocument.



9
10
11
12
13
14
15
# File 'lib/doc_vault/store_document.rb', line 9

def initialize(document:, id:, bucket:, key:)
  @document = document
  @id = id
  @bucket = bucket
  @key = key
  validate_params
end

Class Method Details

.call(document:, id:, bucket:, key:) ⇒ Object



5
6
7
# File 'lib/doc_vault/store_document.rb', line 5

def self.call(document:, id:, bucket:, key:)
  new(document:, id:, bucket:, key:).call
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'lib/doc_vault/store_document.rb', line 17

def call
  database = Database.new(@bucket)
  serialized_doc = DocumentSerializer.serialize(@document)
  encrypted_doc = Encryption.encrypt(serialized_doc, @key)
  database.store(@id, encrypted_doc)
end