lib/mongo/crypt.rb in mongo-2.18.2 vs lib/mongo/crypt.rb in mongo-2.18.3
- old
+ new
@@ -33,7 +33,18 @@
autoload(:RewrapManyDataKeyResult, 'mongo/crypt/rewrap_many_data_key_result')
autoload(:EncryptionIO, 'mongo/crypt/encryption_io')
autoload(:ExplicitEncrypter, 'mongo/crypt/explicit_encrypter')
autoload(:AutoEncrypter, 'mongo/crypt/auto_encrypter')
autoload(:KMS, 'mongo/crypt/kms')
+
+ def validate_ffi!
+ return if defined?(FFI)
+
+ require 'ffi'
+ rescue LoadError => e
+ raise Error::UnmetDependency, 'Cannot enable encryption because the ffi gem ' \
+ "has not been installed. Add \"gem 'ffi'\" to your Gemfile and run " \
+ "\"bundle install\" to install the gem. (#{e.class}: #{e})"
+ end
+ module_function :validate_ffi!
end
end