Sha256: 3a9d7e0080f7fc3d12ed2aac101cfad9bc5bc8eb2980db73f135566c8cae7cb9

Contents?: true

Size: 650 Bytes

Versions: 14

Compression:

Stored size: 650 Bytes

Contents

module Graphiti
  module Adapters
    module ActiveRecord
      class ManyToManySideload < Sideload::ManyToMany
        def through_table_name
          @through_table_name ||= parent_resource_class.model
            .reflections[through.to_s].klass.table_name
        end

        def through_relationship_name
          foreign_key.keys.first
        end

        def infer_foreign_key
          parent_model = parent_resource_class.model
          key = parent_model.reflections[name.to_s].options[:through]
          value = parent_model.reflections[key.to_s].foreign_key.to_sym
          { key => value }
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
graphiti-1.0.alpha.18 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.17 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.16 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.15 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.14 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.12 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.11 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.10 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.9 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.8 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.7 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.6 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.5 lib/graphiti/adapters/active_record/many_to_many_sideload.rb
graphiti-1.0.alpha.4 lib/graphiti/adapters/active_record/many_to_many_sideload.rb