Skip to content

Latest commit

 

History

History
74 lines (27 loc) · 1.02 KB

ClassMethods.rst

File metadata and controls

74 lines (27 loc) · 1.02 KB

ClassMethods

Adds methods to the class related to creating and retrieving reflections.

Constants

Files

Methods

#reflect_on_all_associations

Returns an array containing one reflection for each association declared in the model.

def reflect_on_all_associations(macro = nil)
  association_reflections = reflections.values
  macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections
end

#reflect_on_association

def reflect_on_association(association)
  reflections[association.to_sym]
end