模块:Mongoid::Association::Embedded::EmbedsMany::Buildable
- 定义于:
- lib/mongoid/association/embedded/embeds_many/buildable.rb
Overview
embeds_many 关联的构建器类。
实例方法摘要折叠
-
# 构建 (base, 对象, type = nil, Selected_fields = nil) ⇒ Array<Document ] 文档。
使用提供的关联元数据从属性构建文档。
实例方法详细信息
# 构建 (base, 对象, type = nil, Selected_fields = nil) ⇒ Array< Document ] 文档。
使用提供的关联元数据从属性构建文档。 通过工厂实例化,以确保在合适的情况下使用子类和分配。 这种情况下将返回许多文档。
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mongoid/association/embedded/embeds_many/buildable.rb', line 30 def 构建(基础, 对象, 类型 = nil, created_fields = nil) return [] if 对象.空白? return 对象 if 对象.first.is_a?(文档) docs = [] 对象.每 do |attrs| if _loading? && 基础.持续存在? docs.推动(工厂.execute_from_db(klass, attrs, nil, created_fields, execute_callbacks: false)) else docs.推动(工厂.构建(klass, attrs)) end end docs end |