Sha256: a199f6419fd509043a91cfdb9fdf1c09d4282f87bda1137b25b65dca9061f5bf

Contents?: true

Size: 380 Bytes

Versions: 10

Compression:

Stored size: 380 Bytes

Contents

module GraphitiGql
  module Loaders
    class HasMany < Many
      def assign(parent_records, proxy)
        records = proxy.data
        map = records.group_by { |record| record.send(@sideload.foreign_key) }
        parent_records.each do |pr|
          data = [map[pr.send(@sideload.primary_key)] || [], proxy]
          fulfill(pr, data)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
graphiti_gql-0.2.12 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.11 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.10 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.9 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.8 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.7 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.6 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.5 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.4 lib/graphiti_gql/loaders/has_many.rb
graphiti_gql-0.2.3 lib/graphiti_gql/loaders/has_many.rb