{"push_id":2684306330,"size":1,"distinct_size":1,"ref":"refs/heads/poly_belongs_to","head":"0b178a7c5173c27a7c491ac0d15e17f2e56bc70a","before":"b6dd12311e8f074497357816437ca1c740910d80","commits":[{"sha":"0b178a7c5173c27a7c491ac0d15e17f2e56bc70a","author":{"name":"Lee Richmond","email":"ca6129734cb57f5fdd9c80984cfc9a126440a2ee@bloomberg.net"},"message":"Add polymorphic_belongs_to\n\nImagine you have a table with a foreign key, where the relationship must\nbe fetched not from one other table, but N number of other data sources.\n\nYou can do this with:\n\n```ruby\npolymorphic_belongs_to :credit_card do\n  # Key off of this field to make the switch\n  group_by(:credit_card_type) do\n    on(:Visa) # will use VisaResource\n    on(:Mastercard) # will use MastercardResource\n  end\nend\n```\n\nThis can be customized:\n\n```ruby\npolymorphic_belongs_to :credit_card, foreign_key: :cc_id do\n  group_by(:credit_card_type) do\n    on(:Visa).belongs_to :visa, resource: SpecialVisaResource do\n      # all the normal sideload customizations\n    end\n  end\nend\n```\n\nThe low-level API looks like:\n\n```ruby\nresource.sideloads[:credit_card].children[:visa]\n```\n\n* A lot of the hijinks here are because some values, like inferring the\nforeign key, need to come from the parent. Others need to come from the\nchild.\n* BelongsTo sideloads now accept :group_name to support this\n* The `:as` option introduced for all sideloads. Let's say the\nrelationship name is `:authors` but the model accessor is `:user`. You\ncan now do `has_many :authors, as: :user`.","distinct":true,"url":"https://api.github.com/repos/richmolj/jsonapi_compliable/commits/0b178a7c5173c27a7c491ac0d15e17f2e56bc70a"}]}
{"actor":{"display_login":"richmolj"}}