class LolDba::RelationInspector
Attributes
model_class[R]
reflection_name[R]
reflection_options[R]
Public Class Methods
new(model_class, reflection_options, reflection_name)
click to toggle source
# File lib/lol_dba/index_finding/relation_inspector.rb, line 5 def initialize(model_class, reflection_options, reflection_name) @model_class = model_class @reflection_options = reflection_options @reflection_name = reflection_name end
Public Instance Methods
get_through_foreign_key(target_class, reflection_options)
click to toggle source
# File lib/lol_dba/index_finding/relation_inspector.rb, line 11 def get_through_foreign_key(target_class, reflection_options) # has_many :through reflection = target_class.reflections[reflection_options.options[:through].to_s] # has_and_belongs_to_many reflection ||= reflection_options # Guess foreign key? if reflection.options[:foreign_key] reflection.options[:foreign_key] else "#{target_class.name.tableize.singularize}_id" end end
reflections()
click to toggle source
# File lib/lol_dba/index_finding/relation_inspector.rb, line 26 def reflections model_class.reflections.stringify_keys end