Module: AssociationReporter::Reporter
- Defined in:
- lib/association-reporter/reporter.rb
Instance Method Summary collapse
- #describe(association) ⇒ Object
- #many_to_many_description(reflection) ⇒ Object
- #one_to_many_description(reflection) ⇒ Object
Instance Method Details
#describe(association) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/association-reporter/reporter.rb', line 9 def describe(association) reflection = self.reflect_on_association(association) raise "Can't find an association #{self.name}##{association}" if reflection.nil? if reflection.is_a? ActiveRecord::Reflection::ThroughReflection puts many_to_many_description(reflection) else puts one_to_many_description(reflection) end end |
#many_to_many_description(reflection) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/association-reporter/reporter.rb', line 20 def many_to_many_description(reflection) template_vars = { reflection: reflection, assumption: AssociationReporter::HasManyThroughAssociationAssumption.new(reflection) } AssociationReporter::Template.render('many_to_many.erb', template_vars) end |
#one_to_many_description(reflection) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/association-reporter/reporter.rb', line 28 def one_to_many_description(reflection) template_vars = { reflection: reflection, assumption: AssociationReporter::OneToManyAssociationAssumption.new(reflection) } AssociationReporter::Template.render('one_to_many.erb', template_vars) end |