Class: Mongo::Crypt::Handle Private

Inherits:
Object
  • Object
show all
Defined in:
build/ruby-driver-master/lib/mongo/crypt/handle.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 handle to the libmongocrypt library that wraps a mongocrypt_t object, allowing clients to set options on that object or perform operations such as encryption and decryption

Instance Method Summary collapse

Constructor Details

#initialize(kms_providers, options = {}) ⇒ Handle

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.

Creates a new Handle object and initializes it with options

Parameters:

  • kms_providers (Hash)

    A hash of KMS settings. The only supported key is currently :local. Local KMS options must be passed in the format { local: { key: <master key> } } where the master key is a 96-byte, base64 encoded string.

  • options (Hash) (defaults to: {})

    A hash of options

Options Hash (options):

  • :schema_map (Hash | nil)

    A hash representing the JSON schema of the collection that stores auto encrypted documents.

  • :logger (Logger)

    A Logger object to which libmongocrypt logs will be sent



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'build/ruby-driver-master/lib/mongo/crypt/handle.rb', line 42

def initialize(kms_providers, options={})
  # FFI::AutoPointer uses a custom release strategy to automatically free
  # the pointer once this object goes out of scope
  @mongocrypt = FFI::AutoPointer.new(
    Binding.mongocrypt_new,
    Binding.method(:mongocrypt_destroy)
  )

  @schema_map = options[:schema_map]
  set_schema_map if @schema_map

  @logger = options[:logger]
  set_logger_callback if @logger

  set_crypto_hooks

  set_kms_providers(kms_providers)
  initialize_mongocrypt
end

Instance Method Details

#refFFI::Pointer

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.

Return the reference to the underlying @mongocrypt object

Returns:

  • (FFI::Pointer)


65
66
67
# File 'build/ruby-driver-master/lib/mongo/crypt/handle.rb', line 65

def ref
  @mongocrypt
end