lib/mongoid/kms.rb in mongoid-kms-0.0.28 vs lib/mongoid/kms.rb in mongoid-kms-0.0.29
- old
+ new
@@ -45,10 +45,18 @@
Moped::BSON
elsif defined? BSON
BSON
end
end
+
+ def binary_factory(data)
+ if defined? Moped::BSON
+ Moped::BSON::Binary.new(:generic, data)
+ elsif defined? BSON
+ BSON::Binary.new(data)
+ end
+ end
end
# Instance methods
def set_kms_values
self.class.kms_field_map.each do |field_name, settings|
@@ -66,10 +74,10 @@
end
if value.nil?
self.send("#{encrypted_field_name}=", nil)
else
- self.send("#{encrypted_field_name}=", Mongoid::Kms.bson_class::Binary.new(self.class.encrypt_field(self, field_name, value)))
+ self.send("#{encrypted_field_name}=", Mongoid::Kms.binary_factory(self.class.encrypt_field(self, field_name, value)))
end
end
end
end