Sha256: cb1a99c4490b5e2fa0658f0dfd91b6b178675e16996fdb41784726ae3cb3a3ce

Contents?: true

Size: 594 Bytes

Versions: 32

Compression:

Stored size: 594 Bytes

Contents

module Graphiti::Adapters::ActiveRecord::Inferrence
  # If going AR to AR, use AR introspection
  # If going AR to PORO, fall back to normal inferrence
  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

  def proper_reflection(reflection)
    if (thru = reflection.through_reflection)
      proper_reflection(thru)
    else
      reflection
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
graphiti-1.2.26 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.25 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.21 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.20 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.19 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.18 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.17 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.16 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.15 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.14 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.13 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.12 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.11 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.10 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.9 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.8 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.7 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.6 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.5 lib/graphiti/adapters/active_record/inferrence.rb
graphiti-1.2.4 lib/graphiti/adapters/active_record/inferrence.rb