模块:Mongoid::Association::Referenced::HasAndBelongsToMany::Buildable

包含在:
Mongoid::Association::Referenced::HasAndBelongsToMany
定义于:
lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb

Overview

has_and_belongs_to_many 关联的 Builder 行为。

实例方法摘要折叠

实例方法详细信息

# build (base, object, type = nil, Selected_fields = nil) ⇒ Array< Document >

此构建器要么采用哈希值并查询对象,要么返回文档大量。

例子:

构建文档。

relation.build(association, attrs)

参数:

  • 基础 ( Object )

    基础对象。

  • 对象 ( Object )

    用于构建关联的对象。

  • 类型 string (默认为: nil

    在此上下文中未使用。

  • created_fields (nil) (默认为: nil

    必须为零。

返回:



24
25
26
27
28
29
30
# File 'lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb', line 24

def 构建(基础, 对象, 类型 = nil, created_fields = nil)
  if 查询?(对象)
    query_criteria(对象)
  else
    对象.try(:dup)
  end
end