class LolDba::HasMany
Public Instance Methods
relation_columns()
click to toggle source
# 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_name()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 14 def table_name through_class.table_name end
Private Instance Methods
find_association_fk()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 20 def find_association_fk if (source = reflection_options.options[:source]) association_reflection = through_reflections[source.to_s] return nil if association_reflection.options[:polymorphic] get_through_foreign_key(association_reflection.klass, reflection_options) elsif belongs_to_reflections = through_reflections[reflection_name.singularize] # go to joining model through has_many and find belongs_to belongs_to_reflections.options[:foreign_key] end end
foreign_key()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 39 def foreign_key get_through_foreign_key(model_class, reflection_options) end
through()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 35 def through reflection_options.options[:through] end
through_class()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 31 def through_class reflections[through.to_s].klass end
through_reflections()
click to toggle source
# File lib/lol_dba/index_finding/has_many.rb, line 43 def through_reflections through_class.reflections.stringify_keys end