class Mongoid::Fields::Encrypted

Represents a field that should be encrypted.

Public Class Methods

new(name, options = {}) click to toggle source
Calls superclass method
# File lib/mongoid/fields/encrypted.rb, line 8
def initialize(name, options = {})
  @encryption_options = if options[:encrypt].is_a?(Hash)
                          options[:encrypt]
                        else
                          {}
                        end
  super
end

Public Instance Methods

deterministic?() click to toggle source

@return [ true | false | nil ] Whether the field should be encrypted using a

deterministic encryption algorithm; if not specified, nil is returned.
# File lib/mongoid/fields/encrypted.rb, line 19
def deterministic?
  @encryption_options[:deterministic]
end
key_id() click to toggle source

@return [ String | nil ] The key id to use for encryption; if not specified,

nil is returned.
# File lib/mongoid/fields/encrypted.rb, line 25
def key_id
  @encryption_options[:key_id]
end
key_name_field() click to toggle source

@return [ String | nil ] The name of the field that contains the

key alt name to use for encryption; if not specified, nil is returned.
# File lib/mongoid/fields/encrypted.rb, line 31
def key_name_field
  @encryption_options[:key_name_field]
end
set_key_id(key_id) click to toggle source

Override the key_id for the field.

This method is solely for testing purposes and should not be used in the application code. The schema_map is generated very early in the application lifecycle, and overriding the key_id after that will not have any effect.

@api private

# File lib/mongoid/fields/encrypted.rb, line 43
def set_key_id(key_id)
  @encryption_options[:key_id] = key_id
end