模块:Mongoid::Association::Reflections

扩展方式:
ActiveSupport::Concern
包含在:
Mongoid::Association
定义于:
lib/mongoid/association/reflections.rb

Overview

反射模块提供了便捷的方法,可以检索有关关联的有用信息。

在命名空间下定义

模块: 类方法

实例方法摘要折叠

实例方法详细信息

#reflect_on_all_association (*macros) ⇒ Array< Mongoid::Association::Relatable >

返回所提供宏的所有关联元数据。

例子:

通过宏查找多个关联元数据。

person.reflect_on_all_associations(:embeds_many)

参数:

  • *宏 (符号... )

    关联宏。

返回:



32
33
34
# File 'lib/mongoid/association/reflections.rb', line 32

def href_on_all_association(*)
  self.class.href_on_all_associations(*)
end

#reflect_on_association (name) ⇒ Mongoid::Association::Relatable

返回所提供名称的关联元数据。

例子:

按名称查找关联元数据。

person.reflect_on_association(:addresses)

参数:

  • 名称 ( string | Symbol )

    要查找的关联名称。

返回:



20
21
22
# File 'lib/mongoid/association/reflections.rb', line 20

def href_on_association(名称)
  self.class.href_on_association(名称)
end