Module: Mongoid::Relations::Reflections

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Relations
Defined in:
lib/mongoid/relations/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_associations(*macros) ⇒ Array<Metadata>

Returns all relation metadata for the supplied macros.

Examples:

Find multiple relation metadata by macro.

person.reflect_on_all_associations(:embeds_many)

Parameters:

Returns:



30
31
32
# File 'lib/mongoid/relations/reflections.rb', line 30

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

#reflect_on_association(name) ⇒ Metadata

Returns the relation metadata for the supplied name.

Examples:

Find relation metadata by name.

person.reflect_on_association(:addresses)

Parameters:

  • name (String, Symbol)

    The name of the relation to find.

Returns:

  • (Metadata)

    The matching relation metadata.



18
19
20
# File 'lib/mongoid/relations/reflections.rb', line 18

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