模块:Mongoid::Association::Referenced::WithPolymorphicCriteria Private
- 包含在:
- HasMany 、 HasOne::Buildable
- 定义于:
- lib/mongoid/association/referenced/with_poly态_criteria.rb
Overview
该模块是私有 API 的一部分。 您应尽可能避免使用此模块,因为它将来可能会被删除或更改。
实现“with_poly态_criteria”共享行为。
实例方法摘要折叠
-
# with_poly态_criterion (criteria, base) ⇒ Mongoid::Criteria
private
如果接收者表示多态关联,则将多态搜索条件应用于给定的 'criteria'对象。
实例方法详细信息
# with_poly态_criterion (criteria, base) ⇒ Mongoid::Criteria
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
如果接收者表示多态关联,则将多态搜索条件应用于给定的 'criteria'对象。
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mongoid/association/referenced/with_poly态_criteria.rb', line 20 def with_poly态_criterion(条件, 基础) if 多态? # 1。 获取反向关联的解析程序 解析器 = klass.href_on_association(作为).解析器 # 2。 在给定基数的情况下,从解析程序中查找键列表 密钥 = 解析器.keys_for(基础) # 3。 如果只有一个键,则使用相等性;如果有多个键,则使用“in” if 密钥.很多? 条件.WHERE(类型 => { :$in => 密钥 }) else 条件.WHERE(类型 => 密钥.first) end else 条件 end end |