lib/mongoid.rb in mongoid-7.1.11 vs lib/mongoid.rb in mongoid-7.2.0.rc1
- old
+ new
@@ -4,11 +4,10 @@
require "support/ruby_version"
require "forwardable"
require "time"
require "set"
-require "ruby2_keywords"
require "active_support"
require "active_support/core_ext"
require "active_support/json"
require "active_support/inflector"
@@ -110,6 +109,29 @@
# @example Delegate the configuration methods.
# Mongoid.database = Mongo::Connection.new.db("test")
#
# @since 1.0.0
def_delegators Config, *(Config.public_instance_methods(false) - [ :logger=, :logger ])
+
+
+ # Module used to prepend the discriminator key assignment function to change
+ # the value assigned to the discriminator key to a string.
+ #
+ # @api private
+ module GlobalDiscriminatorKeyAssignment
+ # This class is used for obtaining the method definition location for
+ # Mongoid methods.
+ class InvalidFieldHost
+ include Mongoid::Document
+ end
+
+ def discriminator_key=(value)
+ Mongoid::Fields::Validators::Macro.validate_field_name(InvalidFieldHost, value)
+ value = value.to_s
+ super
+ end
+ end
+
+ class << self
+ prepend GlobalDiscriminatorKeyAssignment
+ end
end