module Graphiti::Adapters::ActiveRecord::Inference

Public Instance Methods

infer_foreign_key() click to toggle source

If going AR to AR, use AR introspection If going AR to PORO, fall back to normal inference

Calls superclass method
# File lib/graphiti/adapters/active_record/inference.rb, line 4
def infer_foreign_key
  parent_model = parent_resource_class.model
  reflection = parent_model.reflections[association_name.to_s]
  if reflection
    reflection = proper_reflection(reflection)
    reflection.foreign_key.to_sym
  else
    super
  end
end

Private Instance Methods

proper_reflection(reflection) click to toggle source
# File lib/graphiti/adapters/active_record/inference.rb, line 17
def proper_reflection(reflection)
  if (thru = reflection.through_reflection)
    proper_reflection(thru)
  else
    reflection
  end
end