Class: Izokatu::Encrypter Abstract

Inherits:
Object
  • Object
show all
Extended by:
Callable
Includes:
Contracts
Defined in:
lib/izokatu/encrypter.rb

Overview

This class is abstract.

Subclasses are containing implementation of #encrypt_data!

Abstract class for encrypters

Constant Summary collapse

DEFAULT_OPTIONS =

Default options for Izokatu::Encrypter

{
  clear_data_string: 'Testing, testing...'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callable

call

Constructor Details

#initialize(clear_data:) ⇒ Encrypter

Initializing option for encryption

Parameters:

Since:

  • 0.1.0



30
31
32
# File 'lib/izokatu/encrypter.rb', line 30

def initialize(clear_data:)
  import_clear_data!(clear_data)
end

Instance Attribute Details

#clear_dataString (readonly)

Returns clear data for encryption.

Returns:

  • (String)

    clear data for encryption



15
16
17
# File 'lib/izokatu/encrypter.rb', line 15

def clear_data
  @clear_data
end

#encrypted_dataHash (readonly)

Returns encrypted data for export.

Returns:

  • (Hash)

    encrypted data for export



17
18
19
# File 'lib/izokatu/encrypter.rb', line 17

def encrypted_data
  @encrypted_data
end

#encrypterObject (readonly)

Returns encrypter instance.

Returns:

  • encrypter instance



13
14
15
# File 'lib/izokatu/encrypter.rb', line 13

def encrypter
  @encrypter
end

Instance Method Details

#encrypt_data!Object (private)

Encrypting data`

Raises:

  • RuntimeError

Since:

  • 0.1.0



63
64
65
# File 'lib/izokatu/encrypter.rb', line 63

def encrypt_data!
  raise 'Not implemented!'
end

#import_clear_data!(clear_data) ⇒ String

Imporing clear data from options

Parameters:

Returns:

  • (String)

    (#clear_data)

Since:

  • 0.1.0



42
43
44
# File 'lib/izokatu/encrypter.rb', line 42

def import_clear_data!(clear_data)
  @clear_data = clear_data || DEFAULT_OPTIONS[:clear_data_string]
end

#performHash

Performing encryption

Returns:

  • (Hash)

    encrypted data with params

Since:

  • 0.1.0



52
53
54
# File 'lib/izokatu/encrypter.rb', line 52

def perform
  encrypt_data!
end