Module: Mongoid::EncryptedField

Extended by:
ActiveSupport::Concern
Included in:
EncryptedDate, EncryptedDateTime, EncryptedHash, EncryptedString, EncryptedTime
Defined in:
lib/mongoid-encrypted-fields/fields/encrypted_field.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#encryptedObject



8
9
10
11
12
13
14
15
# File 'lib/mongoid-encrypted-fields/fields/encrypted_field.rb', line 8

def encrypted
  if frozen?
    @encrypted ||= self.class.encrypt(raw_value)
  else
    # We are mutable - need to encrypt whenever asked
    self.class.encrypt(raw_value)
  end
end

#mongoizeObject

Converts an object of this instance into a database friendly value.



18
19
20
# File 'lib/mongoid-encrypted-fields/fields/encrypted_field.rb', line 18

def mongoize
  encrypted
end

#raw_valueObject

Provide string to be encrypted and stored in Mongo DB



23
24
25
# File 'lib/mongoid-encrypted-fields/fields/encrypted_field.rb', line 23

def raw_value
  to_s
end