Module: Mongoid::Encryptable::ClassMethods
- Defined in:
- lib/mongoid/encryptable.rb
Instance Method Summary collapse
-
#encrypt_with(options = {}) ⇒ Object
Set the encryption metadata for the model.
-
#encrypted? ⇒ true | false
Whether the model is encrypted.
-
#set_key_id(key_id) ⇒ Object
private
Override the key_id for the model.
Instance Method Details
#encrypt_with(options = {}) ⇒ Object
Set the encryption metadata for the model. Parameters set here will be used to encrypt the fields of the model, unless overridden on the field itself.
is deterministic or not.
27 28 29 |
# File 'lib/mongoid/encryptable.rb', line 27 def encrypt_with( = {}) self. = end |
#encrypted? ⇒ true | false
Whether the model is encrypted. It means that either the encrypt_with method was called on the model, or at least one of the fields is encrypted.
36 37 38 |
# File 'lib/mongoid/encryptable.rb', line 36 def encrypted? !.empty? || fields.any? { |_, field| field.is_a?(Mongoid::Fields::Encrypted) } end |
#set_key_id(key_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override the key_id for the model.
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.
48 49 50 |
# File 'lib/mongoid/encryptable.rb', line 48 def set_key_id(key_id) self.[:key_id] = key_id end |