22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/symmetric_encryption/extensions/mongo_mapper/plugins/encrypted_key.rb', line 22
def encrypted_key(key_name, type, full_options = {})
full_options = full_options.is_a?(Hash) ? full_options.dup : {}
options = full_options.delete(:encrypted) || {}
encrypted_key_name = options.delete(:encrypt_as) || "encrypted_#{key_name}"
options[:type] = COERCION_MAP[type] unless %i[yaml json].include?(options[:type])
raise(ArgumentError, "Invalid type: #{type.inspect}. Valid types: #{COERCION_MAP.keys.join(',')}") unless options[:type]
SymmetricEncryption::Generator.generate_decrypted_accessors(self, key_name, encrypted_key_name, options)
key(encrypted_key_name, String, full_options)
end
|