Class: Underlock::EncryptedEntity

Inherits:
Object
  • Object
show all
Defined in:
lib/underlock/encrypted_entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value: nil, encrypted_file: nil, key:, iv:) ⇒ EncryptedEntity

Returns a new instance of EncryptedEntity.



5
6
7
8
9
10
# File 'lib/underlock/encrypted_entity.rb', line 5

def initialize(value: nil, encrypted_file: nil, key:, iv:)
  @encrypted_file = encrypted_file
  @value = value
  @key = key
  @iv = iv
end

Instance Attribute Details

#encrypted_fileObject

Returns the value of attribute encrypted_file.



4
5
6
# File 'lib/underlock/encrypted_entity.rb', line 4

def encrypted_file
  @encrypted_file
end

#ivObject

Returns the value of attribute iv.



4
5
6
# File 'lib/underlock/encrypted_entity.rb', line 4

def iv
  @iv
end

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/underlock/encrypted_entity.rb', line 4

def key
  @key
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/underlock/encrypted_entity.rb', line 4

def value
  @value
end

Instance Method Details

#decryptObject



12
13
14
15
# File 'lib/underlock/encrypted_entity.rb', line 12

def decrypt
  return Encryptor.new.decrypt(self) if value
  return FileEncryptor.new.decrypt(self) if encrypted_file
end

#inspectObject



17
18
19
# File 'lib/underlock/encrypted_entity.rb', line 17

def inspect
  self.to_s
end