Sha256: 96025ab7df85bd2e434f9f2965dd7ea9b4ceff6e4992b6b4e9c0228b027b6348
Contents?: true
Size: 569 Bytes
Versions: 1
Compression:
Stored size: 569 Bytes
Contents
class JsonapiCompliable::Sideload::ManyToMany < JsonapiCompliable::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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsonapi_compliable-1.0.alpha.2 | lib/jsonapi_compliable/sideload/many_to_many.rb |