Module: Mongoid::Relations::Reflections::ClassMethods

Defined in:
lib/mongoid/relations/reflections.rb

Overview

:nodoc

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:



39
40
41
# File 'lib/mongoid/relations/reflections.rb', line 39

def reflect_on_all_associations(*macros)
  relations.values.select { |meta| macros.include?(meta.macro) }
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.



27
28
29
# File 'lib/mongoid/relations/reflections.rb', line 27

def reflect_on_association(name)
  relations[name.to_s]
end