模块:Mongoid::Association::Constrainable
- 包含在:
- Relatable
- 定义于:
- lib/mongoid/association/constrainable.rb
Overview
用于根据文档存储的 ID 类型将外键值转换为正确的类型。
实例方法摘要折叠
-
# convert_to_foreign_key (object) ⇒ 对象
将提供的对象转换为适当的类型,以设置为关联的外键。
实例方法详细信息
# convert_to_foreign_key (对象) ⇒对象
将提供的对象转换为适当的类型,以设置为关联的外键。
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/association/constrainable.rb', line 20 def convert_to_foreign_key(对象) return convert_polymorphic(对象) if 多态? 字段 = lation_class.字段[" _id "] if lation_class.using_object_id? BSON::ObjectId.mongoize(对象) elsif 对象.is_a?(::阵列) 对象.地图!{ |obj| 字段.mongoize(obj) } else 字段.mongoize(对象) end end |