Module: Mongoid::Association::Reflections

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Association
Defined in:
build/mongoid-master/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<Association>

Returns all association metadata for the supplied macros.

Examples:

Find multiple association metadata by macro.

person.reflect_on_all_associations(:embeds_many)

Parameters:

  • macros (Array<Symbol>)

    The association macros.

Returns:

  • (Array<Association>)

    The matching association metadata.



32
33
34
# File 'build/mongoid-master/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) ⇒ Association

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 'build/mongoid-master/lib/mongoid/association/reflections.rb', line 20

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