请参阅@rfunduk 对当前发布的 2.4.10 版本的回答。
在 master 分支中,它发生了变化。您现在可以在需要的origin
库中找到它mongoid
:
https://github.com/mongoid/origin/blob/master/lib/origin/extensions/symbol.rb,特别是这个方法:
module Origin
module Extensions
module Symbol
# ...
module ClassMethods
# Adds a method on symbol as a convenience for the MongoDB operator.
#
# @example Add the $in method.
# Symbol.add_key(:in, "$in")
#
# @param [ Symbol ] name The name of the method.
# @param [ Symbol ] strategy The name of the merge strategy.
# @param [ String ] operator The MongoDB operator.
# @param [ String ] additional The additional MongoDB operator.
#
# @since 1.0.0
def add_key(name, strategy, operator, additional = nil, &block)
define_method(name) do
method = "__#{strategy}__".to_sym
Key.new(self, method, operator, additional, &block)
end
end
# ...
end
end
end
end
它根据主库中列出的匹配器添加 、 等gt
方法(参见文件和文件夹)。gte
mongoid
strategies.rb
matchers/