Class: Mongoid::EncryptedString

Inherits:
String
  • Object
show all
Defined in:
lib/mongoid/encrypted_string.rb,
lib/mongoid/encrypted_string/version.rb

Constant Summary collapse

VERSION =
'0.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.keyObject

Returns the value of attribute key.



12
13
14
# File 'lib/mongoid/encrypted_string.rb', line 12

def key
  @key
end

Class Method Details

.configObject



24
25
26
# File 'lib/mongoid/encrypted_string.rb', line 24

def config
  self
end

.demongoize(string) ⇒ Object



18
19
20
21
22
# File 'lib/mongoid/encrypted_string.rb', line 18

def demongoize(string)
  return if string.nil?
  
  new(aes.decrypt(string))
end

.mongoize(string) ⇒ Object



14
15
16
# File 'lib/mongoid/encrypted_string.rb', line 14

def mongoize(string)
  aes.encrypt(string)
end

Instance Method Details

#mongoizeObject



7
8
9
# File 'lib/mongoid/encrypted_string.rb', line 7

def mongoize
  self.class.mongoize(self)
end