Top Level Namespace
Defined Under Namespace
Modules: SymmetricEncryption Classes: SymmetricEncryptionValidator
Instance Method Summary collapse
-
#encrypted ⇒ Field
The generated field.
Instance Method Details
#encrypted ⇒ Field
Returns The generated field.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/symmetric_encryption/railties/mongoid_encrypted.rb', line 91 Mongoid::Fields.option :encrypted do |model, field, | if != false = .is_a?(Hash) ? .dup : {} encrypted_field_name = field.name # Support overriding the name of the decrypted attribute decrypted_field_name = .delete(:decrypt_as) if decrypted_field_name.nil? && encrypted_field_name.to_s.start_with?("encrypted_") decrypted_field_name = encrypted_field_name.to_s["encrypted_".length..-1] end if decrypted_field_name.nil? raise(ArgumentError, "SymmetricEncryption for Mongoid. Encryption enabled for field #{encrypted_field_name}. It must either start with 'encrypted_' or the option :decrypt_as must be supplied") end SymmetricEncryption::Generator.generate_decrypted_accessors(model, decrypted_field_name, encrypted_field_name, ) end end |