module Mongoid::Association::Reflections

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

Public Instance Methods

reflect_on_all_association(*macros) click to toggle source

Returns all association metadata for the supplied macros.

@example Find multiple association metadata by macro.

person.reflect_on_all_associations(:embeds_many)

@param [ Array<Symbol> ] macros The association macros.

@return [ Array<Association> ] The matching association metadata.

# 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) click to toggle source

Returns the association metadata for the supplied name.

@example Find association metadata by name.

person.reflect_on_association(:addresses)

@param [ String, Symbol ] name The name of the association to find.

@return [ Association ] The matching association metadata.

# File lib/mongoid/association/reflections.rb, line 20
def reflect_on_association(name)
  self.class.reflect_on_association(name)
end