Module: Mongoid::Association::Reflections

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Association
Defined in:
lib/mongoid/association/reflections.rb

Overview

The reflections module provides convenience methods that can retrieve useful information about associations.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

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

Returns all association metadata for the supplied macros.

Examples:

Find multiple association metadata by macro.

person.reflect_on_all_associations(:embeds_many)

Parameters:

  • *macros (Symbol...)

    The association macros.

Returns:



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

def reflect_on_all_association(*macros)
  self.class.reflect_on_all_associations(*macros)
end

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

Returns the association metadata for the supplied name.

Examples:

Find association metadata by name.

person.reflect_on_association(:addresses)

Parameters:

  • name (String | Symbol)

    The name of the association to find.

Returns:



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

def reflect_on_association(name)
  self.class.reflect_on_association(name)
end