123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Association::Reflections

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Concern
Defined in: lib/mongoid/association/reflections.rb

Overview

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

Instance Method Summary

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:

[ GitHub ]

  
# 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:

[ GitHub ]

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

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