lib/symmetric_encryption.rb in symmetric-encryption-4.1.0.beta1 vs lib/symmetric_encryption.rb in symmetric-encryption-4.1.0
- old
+ new
@@ -27,15 +27,36 @@
end
end
# @formatter:on
# Add support for other libraries only if they have already been loaded
-require 'symmetric_encryption/railtie' if defined?(Rails)
-if defined?(ActiveRecord::Base) && !defined?(AttrEncrypted::Version)
- require 'symmetric_encryption/extensions/active_record/base'
+
+begin
+ require 'rails/railtie'
+ require 'symmetric_encryption/railtie' if defined?(Rails)
+rescue LoadError
end
-require 'symmetric_encryption/railties/symmetric_encryption_validator' if defined?(ActiveModel)
-require 'symmetric_encryption/extensions/mongoid/encrypted' if defined?(Mongoid)
+
+begin
+ require 'active_record'
+ if defined?(ActiveRecord::Base) && !defined?(AttrEncrypted::Version)
+ require 'symmetric_encryption/extensions/active_record/base'
+ end
+rescue LoadError
+end
+
+begin
+ require 'active_model'
+ require 'symmetric_encryption/railties/symmetric_encryption_validator' if defined?(ActiveModel)
+rescue LoadError
+end
+
+begin
+ require 'mongoid'
+ require 'symmetric_encryption/extensions/mongoid/encrypted' if defined?(Mongoid)
+rescue LoadError
+end
+
if defined?(MongoMapper)
warn 'MongoMapper support is deprecated. Upgrade to Mongoid.'
require 'symmetric_encryption/extensions/mongo_mapper/plugins/encrypted_key'
end