Module: Encryptor::String

Defined in:
lib/encryptor/string.rb

Overview

Adds encrypt and decrypt methods to strings

Instance Method Summary collapse

Instance Method Details

#decrypt(options = {}) ⇒ Object

Returns a new string containing the decrypted version of itself



15
16
17
# File 'lib/encryptor/string.rb', line 15

def decrypt(options = {})
  Encryptor.decrypt(options.merge(value: self))
end

#decrypt!(options = {}) ⇒ Object

Replaces the contents of a string with the decrypted version of itself



20
21
22
# File 'lib/encryptor/string.rb', line 20

def decrypt!(options = {})
  replace decrypt(options)
end

#encrypt(options = {}) ⇒ Object

Returns a new string containing the encrypted version of itself



5
6
7
# File 'lib/encryptor/string.rb', line 5

def encrypt(options = {})
  Encryptor.encrypt(options.merge(value: self))
end

#encrypt!(options = {}) ⇒ Object

Replaces the contents of a string with the encrypted version of itself



10
11
12
# File 'lib/encryptor/string.rb', line 10

def encrypt!(options ={})
  replace encrypt(options)
end