Class: LolDba::HasMany

Inherits:
RelationInspector show all
Defined in:
lib/lol_dba/index_finding/has_many.rb

Instance Attribute Summary

Attributes inherited from RelationInspector

#model_class, #reflection_name, #reflection_options

Instance Method Summary collapse

Methods inherited from RelationInspector

#get_through_foreign_key, #initialize, #reflections

Constructor Details

This class inherits a constructor from LolDba::RelationInspector

Instance Method Details

#relation_columnsObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/lol_dba/index_finding/has_many.rb', line 3

def relation_columns
  # has_many tables are threaten by the other side of the relation
  return nil unless through && reflections[through.to_s]

  # FIXME: currently we don't support :through =>
  # :another_regular_has_many_and_non_through_relation
  if (association_foreign_key = find_association_fk).present?
    [association_foreign_key, foreign_key].map(&:to_s).sort
  end
end

#table_nameObject



14
15
16
# File 'lib/lol_dba/index_finding/has_many.rb', line 14

def table_name
  through_class.table_name
end