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

- (Array<Metadata>) reflect_on_all_associations(*macros)

Returns all relation metadata for the supplied macros.

Examples:

Find multiple relation metadata by macro.

person.reflect_on_all_associations(:embeds_many)


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

- (Metadata) reflect_on_association(name)

Returns the relation metadata for the supplied name.

Examples:

Find relation metadata by name.

person.reflect_on_association(:addresses)


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

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