Class: EncryptAttributes::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/encrypt_attributes/encryptor.rb

Instance Method Summary collapse

Instance Method Details

#decrypt(value) ⇒ Object



18
19
20
21
# File 'lib/encrypt_attributes/encryptor.rb', line 18

def decrypt(value)
  return value if value.to_s.empty?
  message_encryptor.decrypt_and_verify(value)
end

#encrypt(value) ⇒ Object



13
14
15
16
# File 'lib/encrypt_attributes/encryptor.rb', line 13

def encrypt(value)
  return value if value.to_s.empty?
  message_encryptor.encrypt_and_sign(value)
end

#message_encryptorObject



23
24
25
# File 'lib/encrypt_attributes/encryptor.rb', line 23

def message_encryptor
  ActiveSupport::MessageEncryptor.new(self.class.secret)
end