Class: GraphitiGql::Loaders::HasOne

Inherits:
Many
  • Object
show all
Defined in:
lib/graphiti_gql/loaders/has_one.rb

Instance Method Summary collapse

Methods inherited from Many

factory, #initialize, #perform

Constructor Details

This class inherits a constructor from GraphitiGql::Loaders::Many

Instance Method Details

#assign(parent_records, proxy) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/graphiti_gql/loaders/has_one.rb', line 4

def assign(parent_records, proxy)
  records = proxy.data
  parent_records.each do |pr|
    corresponding = records.find do |r|
      r.send(@sideload.foreign_key) == pr.send(@sideload.primary_key)
    end
    fulfill(pr, corresponding)
  end
end