Class: Mongo::Crypt::ExplicitEncryptionContext Private
- Defined in:
- build/ruby-driver-v2.17/lib/mongo/crypt/explicit_encryption_context.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A Context object initialized for explicit encryption
Instance Attribute Summary
Attributes inherited from Context
Instance Method Summary collapse
-
#initialize(mongocrypt, io, doc, options = {}) ⇒ ExplicitEncryptionContext
constructor
private
Create a new ExplicitEncryptionContext object.
Methods inherited from Context
Constructor Details
#initialize(mongocrypt, io, doc, options = {}) ⇒ ExplicitEncryptionContext
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.
Create a new ExplicitEncryptionContext object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'build/ruby-driver-v2.17/lib/mongo/crypt/explicit_encryption_context.rb', line 45 def initialize(mongocrypt, io, doc, ={}) super(mongocrypt, io) if [:key_id].nil? && [:key_alt_name].nil? raise ArgumentError.new( 'The :key_id and :key_alt_name options cannot both be nil. ' + 'Specify a :key_id option or :key_alt_name option (but not both)' ) end if [:key_id] && [:key_alt_name] raise ArgumentError.new( 'The :key_id and :key_alt_name options cannot both be present. ' + 'Identify the data key by specifying its id with the :key_id ' + 'option or specifying its alternate name with the :key_alt_name option' ) end # Set the key id or key alt name option on the mongocrypt_ctx_t object # and raise an exception if the key_id or key_alt_name is invalid. if [:key_id] unless [:key_id].is_a?(BSON::Binary) && [:key_id].type == :uuid raise ArgumentError.new( "Expected the :key_id option to be a BSON::Binary object with " + "type :uuid. #{[:key_id]} is an invalid :key_id option" ) end Binding.ctx_setopt_key_id(self, [:key_id].data) elsif [:key_alt_name] unless [:key_alt_name].is_a?(String) raise ArgumentError.new(':key_alt_name option must be a String') end Binding.ctx_setopt_key_alt_names(self, [[:key_alt_name]]) end # Set the algorithm option on the mongocrypt_ctx_t object and raises # an exception if the algorithm is invalid. Binding.ctx_setopt_algorithm(self, [:algorithm]) # Initializes the mongocrypt_ctx_t object for explicit encryption and # passes in the value to be encrypted. Binding.ctx_explicit_encrypt_init(self, doc) end |