模块:Mongoid::Association::Embedded::EmbeddedIn::Buildable

包括:
Threaded::Lifecycle
包含在:
Mongoid::Association::Embedded::EmbeddedIn
定义于:
lib/mongoid/association/embedded/embedded_in/buildable.rb

Overview

embedded_in 关联的构建器行为。

实例方法摘要折叠

实例方法详细信息

# 构建 (base, 对象, type = nil, Selected_fields = nil) ⇒文档

该构建器实际上并不构建任何内容,只是返回父构建器,因为它应该已经被实例化。

例子:

构建文档。

Builder.new(meta, attrs).build

参数:

  • 基础 (文档)

    对象。

  • 对象 (文档| 哈希)

    父哈希或文档。

  • 类型 string (默认为: nil

    在此上下文中未使用。

  • created_fields 哈希 (默认为: nil

    通过 #only 检索的字段。 如果指定了selected_fields,则无法在构建的文档中访问未在其中列出的字段。

返回:

  • (文档)

    单个文档。



27
28
29
30
31
32
33
34
# File 'lib/mongoid/association/embedded/embedded_in/buildable.rb', line 27

def 构建(基础, 对象, 类型 = nil, created_fields = nil)
  return 对象 除非 对象.is_a?(哈希)
  if _loading?
    工厂.from_db(klass, 对象, nil, created_fields)
  else
    工厂.构建(klass, 对象)
  end
end