Sha256: b2ea11bc870c12a4083c0ae987475f5a54a0b25f496fe0ad223f9c922cd50374
Contents?: true
Size: 551 Bytes
Versions: 2
Compression:
Stored size: 551 Bytes
Contents
class Graphiti::Sideload::ManyToMany < Graphiti::Sideload def type :many_to_many end def through foreign_key.keys.first end def true_foreign_key foreign_key.values.first end def infer_foreign_key raise 'You must explicitly pass :foreign_key for many-to-many relaitonships, or override in subclass to return a hash.' end def assign_each(parent, children) children.select do |c| match = ->(ct) { ct.send(true_foreign_key) == parent.send(primary_key) } c.send(through).any?(&match) end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
graphiti-1.0.alpha.1 | lib/graphiti/sideload/many_to_many.rb |
graphiti-rb-1.0.alpha.1 | lib/graphiti/sideload/many_to_many.rb |