{"action":"closed","number":252,"pull_request":{"url":"https://api.github.com/repos/Shopify/identity_cache/pulls/252","id":56523269,"html_url":"https://github.com/Shopify/identity_cache/pull/252","diff_url":"https://github.com/Shopify/identity_cache/pull/252.diff","patch_url":"https://github.com/Shopify/identity_cache/pull/252.patch","issue_url":"https://api.github.com/repos/Shopify/identity_cache/issues/252","number":252,"state":"closed","locked":false,"title":"Allow prefetch_associations to be used on existing records.","user":{"login":"dylanahsmith","id":954402,"avatar_url":"https://avatars.githubusercontent.com/u/954402?v=3","gravatar_id":"","url":"https://api.github.com/users/dylanahsmith","html_url":"https://github.com/dylanahsmith","followers_url":"https://api.github.com/users/dylanahsmith/followers","following_url":"https://api.github.com/users/dylanahsmith/following{/other_user}","gists_url":"https://api.github.com/users/dylanahsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanahsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanahsmith/subscriptions","organizations_url":"https://api.github.com/users/dylanahsmith/orgs","repos_url":"https://api.github.com/users/dylanahsmith/repos","events_url":"https://api.github.com/users/dylanahsmith/events{/privacy}","received_events_url":"https://api.github.com/users/dylanahsmith/received_events","type":"User","site_admin":false},"body":"@boourns & @eapache for review\r\n\r\n## Problem\r\n\r\nI would like to be able to prefetch associations on records which have already been loaded.\r\n\r\nAn example of where this can be useful is when performing an update on a record.  The record needs to be loaded from the database to avoid propagating cache corruption, but that prevents prefetching unloaded associations using the existing record when creating an HTTP response that corresponds to that update.\r\n\r\nThis can also be useful for normalized associations, like when calling `fetch_#{association}` on a `cache_belongs_to` association or on an id embedded association, which doesn't support the `:includes` option, since it would complicate memorization.\r\n\r\n## Solution\r\n\r\nI made the `prefetch_associations` method public and made it work with records not loaded from IDC.  Embedded associations are loaded by fetching the owner of the association from the cache, then moving the loaded association records onto the records passed to `prefetch_associations`.","created_at":"2016-01-19T20:48:42Z","updated_at":"2016-01-20T21:33:43Z","closed_at":"2016-01-20T21:33:43Z","merged_at":"2016-01-20T21:33:43Z","merge_commit_sha":"c5880e71bbe5d5aef3a04f9e76ba889879037bbc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/identity_cache/pulls/252/commits","review_comments_url":"https://api.github.com/repos/Shopify/identity_cache/pulls/252/comments","review_comment_url":"https://api.github.com/repos/Shopify/identity_cache/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/identity_cache/issues/252/comments","statuses_url":"https://api.github.com/repos/Shopify/identity_cache/statuses/03997ae00b24e61089b83da3e41d550b173243a9","head":{"label":"Shopify:prefetch-associations","ref":"prefetch-associations","sha":"03997ae00b24e61089b83da3e41d550b173243a9","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":8472417,"name":"identity_cache","full_name":"Shopify/identity_cache","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/identity_cache","description":"IdentityCache is a blob level caching solution to plug into ActiveRecord. Don't #find, #fetch!","fork":false,"url":"https://api.github.com/repos/Shopify/identity_cache","forks_url":"https://api.github.com/repos/Shopify/identity_cache/forks","keys_url":"https://api.github.com/repos/Shopify/identity_cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/identity_cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/identity_cache/teams","hooks_url":"https://api.github.com/repos/Shopify/identity_cache/hooks","issue_events_url":"https://api.github.com/repos/Shopify/identity_cache/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/identity_cache/events","assignees_url":"https://api.github.com/repos/Shopify/identity_cache/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/identity_cache/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/identity_cache/tags","blobs_url":"https://api.github.com/repos/Shopify/identity_cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/identity_cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/identity_cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/identity_cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/identity_cache/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/identity_cache/languages","stargazers_url":"https://api.github.com/repos/Shopify/identity_cache/stargazers","contributors_url":"https://api.github.com/repos/Shopify/identity_cache/contributors","subscribers_url":"https://api.github.com/repos/Shopify/identity_cache/subscribers","subscription_url":"https://api.github.com/repos/Shopify/identity_cache/subscription","commits_url":"https://api.github.com/repos/Shopify/identity_cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/identity_cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/identity_cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/identity_cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/identity_cache/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/identity_cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/identity_cache/merges","archive_url":"https://api.github.com/repos/Shopify/identity_cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/identity_cache/downloads","issues_url":"https://api.github.com/repos/Shopify/identity_cache/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/identity_cache/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/identity_cache/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/identity_cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/identity_cache/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/identity_cache/releases{/id}","created_at":"2013-02-28T05:19:14Z","updated_at":"2016-01-18T17:05:15Z","pushed_at":"2016-01-20T21:33:43Z","git_url":"git://github.com/Shopify/identity_cache.git","ssh_url":"git@github.com:Shopify/identity_cache.git","clone_url":"https://github.com/Shopify/identity_cache.git","svn_url":"https://github.com/Shopify/identity_cache","homepage":"http://shopify.github.io/identity_cache","size":731,"stargazers_count":1104,"watchers_count":1104,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":118,"mirror_url":null,"open_issues_count":5,"forks":118,"open_issues":5,"watchers":1104,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"8843be6ccfacff7f7efb2ed00032cbebfa12751e","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":8472417,"name":"identity_cache","full_name":"Shopify/identity_cache","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/identity_cache","description":"IdentityCache is a blob level caching solution to plug into ActiveRecord. Don't #find, #fetch!","fork":false,"url":"https://api.github.com/repos/Shopify/identity_cache","forks_url":"https://api.github.com/repos/Shopify/identity_cache/forks","keys_url":"https://api.github.com/repos/Shopify/identity_cache/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/identity_cache/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/identity_cache/teams","hooks_url":"https://api.github.com/repos/Shopify/identity_cache/hooks","issue_events_url":"https://api.github.com/repos/Shopify/identity_cache/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/identity_cache/events","assignees_url":"https://api.github.com/repos/Shopify/identity_cache/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/identity_cache/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/identity_cache/tags","blobs_url":"https://api.github.com/repos/Shopify/identity_cache/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/identity_cache/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/identity_cache/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/identity_cache/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/identity_cache/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/identity_cache/languages","stargazers_url":"https://api.github.com/repos/Shopify/identity_cache/stargazers","contributors_url":"https://api.github.com/repos/Shopify/identity_cache/contributors","subscribers_url":"https://api.github.com/repos/Shopify/identity_cache/subscribers","subscription_url":"https://api.github.com/repos/Shopify/identity_cache/subscription","commits_url":"https://api.github.com/repos/Shopify/identity_cache/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/identity_cache/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/identity_cache/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/identity_cache/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/identity_cache/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/identity_cache/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/identity_cache/merges","archive_url":"https://api.github.com/repos/Shopify/identity_cache/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/identity_cache/downloads","issues_url":"https://api.github.com/repos/Shopify/identity_cache/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/identity_cache/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/identity_cache/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/identity_cache/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/identity_cache/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/identity_cache/releases{/id}","created_at":"2013-02-28T05:19:14Z","updated_at":"2016-01-18T17:05:15Z","pushed_at":"2016-01-20T21:33:43Z","git_url":"git://github.com/Shopify/identity_cache.git","ssh_url":"git@github.com:Shopify/identity_cache.git","clone_url":"https://github.com/Shopify/identity_cache.git","svn_url":"https://github.com/Shopify/identity_cache","homepage":"http://shopify.github.io/identity_cache","size":731,"stargazers_count":1104,"watchers_count":1104,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":118,"mirror_url":null,"open_issues_count":5,"forks":118,"open_issues":5,"watchers":1104,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/identity_cache/pulls/252"},"html":{"href":"https://github.com/Shopify/identity_cache/pull/252"},"issue":{"href":"https://api.github.com/repos/Shopify/identity_cache/issues/252"},"comments":{"href":"https://api.github.com/repos/Shopify/identity_cache/issues/252/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/identity_cache/pulls/252/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/identity_cache/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/identity_cache/pulls/252/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/identity_cache/statuses/03997ae00b24e61089b83da3e41d550b173243a9"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"dylanahsmith","id":954402,"avatar_url":"https://avatars.githubusercontent.com/u/954402?v=3","gravatar_id":"","url":"https://api.github.com/users/dylanahsmith","html_url":"https://github.com/dylanahsmith","followers_url":"https://api.github.com/users/dylanahsmith/followers","following_url":"https://api.github.com/users/dylanahsmith/following{/other_user}","gists_url":"https://api.github.com/users/dylanahsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanahsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanahsmith/subscriptions","organizations_url":"https://api.github.com/users/dylanahsmith/orgs","repos_url":"https://api.github.com/users/dylanahsmith/repos","events_url":"https://api.github.com/users/dylanahsmith/events{/privacy}","received_events_url":"https://api.github.com/users/dylanahsmith/received_events","type":"User","site_admin":false},"comments":2,"review_comments":19,"commits":4,"additions":152,"deletions":82,"changed_files":3}}