module Mongoid::Relations::Reflections::ClassMethods

Public Instance Methods

reflect_on_all_associations(*macros) click to toggle source

Returns all relation metadata for the supplied macros.

@example Find multiple relation metadata by macro.

Person.reflect_on_all_associations(:embeds_many)

@param [ Array<Symbol> ] *macros The relation macros.

@return [ Array<Metadata> ] The matching relation metadata.

# File lib/mongoid/relations/reflections.rb, line 56
def reflect_on_all_associations(*macros)
  association_reflections = relations.values
  association_reflections.select! { |reflection| macros.include?(reflection.macro) } unless macros.empty?
  association_reflections
end
reflect_on_association(name) click to toggle source

Returns the relation metadata for the supplied name.

@example Find relation metadata by name.

Person.reflect_on_association(:addresses)

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

@return [ Metadata ] The matching relation metadata.

# File lib/mongoid/relations/reflections.rb, line 44
def reflect_on_association(name)
  relations[name.to_s]
end