{"action":"closed","number":37,"pull_request":{"url":"https://api.github.com/repos/jo/backbone-pouch/pulls/37","id":28750489,"html_url":"https://github.com/jo/backbone-pouch/pull/37","diff_url":"https://github.com/jo/backbone-pouch/pull/37.diff","patch_url":"https://github.com/jo/backbone-pouch/pull/37.patch","issue_url":"https://api.github.com/repos/jo/backbone-pouch/issues/37","number":37,"state":"closed","locked":false,"title":"Allow db to be specified as a function","user":{"login":"andymorris","id":324914,"avatar_url":"https://avatars.githubusercontent.com/u/324914?v=3","gravatar_id":"","url":"https://api.github.com/users/andymorris","html_url":"https://github.com/andymorris","followers_url":"https://api.github.com/users/andymorris/followers","following_url":"https://api.github.com/users/andymorris/following{/other_user}","gists_url":"https://api.github.com/users/andymorris/gists{/gist_id}","starred_url":"https://api.github.com/users/andymorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andymorris/subscriptions","organizations_url":"https://api.github.com/users/andymorris/orgs","repos_url":"https://api.github.com/users/andymorris/repos","events_url":"https://api.github.com/users/andymorris/events{/privacy}","received_events_url":"https://api.github.com/users/andymorris/received_events","type":"User","site_admin":false},"body":"This is a simple change to allow `db` to be specified as a function that returns a `PouchDB`, while still supporting `db` directly referring to a specific `PouchDB` instance, by using `_.result`.\r\n\r\nMy use case for this is that users can essentially have multiple projects within my app, where each project has its own PouchDB but all projects use the same Backbone models. Currently I have to go through my models and collections and re-override `sync`/`fetch`/etc with the correct `db` any time a user changes projects. With this change, I can specify `db` as a function that returns the \"current\" PouchDB.\r\n\r\nAll tests pass, but I'm not sure of the best way to add tests for these changes, short of running all the existing tests twice (once where `db` is a PouchDB and once where `db` is a function that returns a PouchDB). I'd be happy to add or modify tests if I could get a suggestion as to the best approach.","created_at":"2015-02-05T18:52:23Z","updated_at":"2015-02-27T12:09:36Z","closed_at":"2015-02-27T12:09:36Z","merged_at":"2015-02-27T12:09:36Z","merge_commit_sha":"7b897d77f8213e3adb41f9a9ff193516e38ca8f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jo/backbone-pouch/pulls/37/commits","review_comments_url":"https://api.github.com/repos/jo/backbone-pouch/pulls/37/comments","review_comment_url":"https://api.github.com/repos/jo/backbone-pouch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jo/backbone-pouch/issues/37/comments","statuses_url":"https://api.github.com/repos/jo/backbone-pouch/statuses/056cf10b9f1278fdf76b8785a181420cdd64aac4","head":{"label":"andymorris:db_as_function","ref":"db_as_function","sha":"056cf10b9f1278fdf76b8785a181420cdd64aac4","user":{"login":"andymorris","id":324914,"avatar_url":"https://avatars.githubusercontent.com/u/324914?v=3","gravatar_id":"","url":"https://api.github.com/users/andymorris","html_url":"https://github.com/andymorris","followers_url":"https://api.github.com/users/andymorris/followers","following_url":"https://api.github.com/users/andymorris/following{/other_user}","gists_url":"https://api.github.com/users/andymorris/gists{/gist_id}","starred_url":"https://api.github.com/users/andymorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andymorris/subscriptions","organizations_url":"https://api.github.com/users/andymorris/orgs","repos_url":"https://api.github.com/users/andymorris/repos","events_url":"https://api.github.com/users/andymorris/events{/privacy}","received_events_url":"https://api.github.com/users/andymorris/received_events","type":"User","site_admin":false},"repo":{"id":30371209,"name":"backbone-pouch","full_name":"andymorris/backbone-pouch","owner":{"login":"andymorris","id":324914,"avatar_url":"https://avatars.githubusercontent.com/u/324914?v=3","gravatar_id":"","url":"https://api.github.com/users/andymorris","html_url":"https://github.com/andymorris","followers_url":"https://api.github.com/users/andymorris/followers","following_url":"https://api.github.com/users/andymorris/following{/other_user}","gists_url":"https://api.github.com/users/andymorris/gists{/gist_id}","starred_url":"https://api.github.com/users/andymorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andymorris/subscriptions","organizations_url":"https://api.github.com/users/andymorris/orgs","repos_url":"https://api.github.com/users/andymorris/repos","events_url":"https://api.github.com/users/andymorris/events{/privacy}","received_events_url":"https://api.github.com/users/andymorris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andymorris/backbone-pouch","description":"Backbone PouchDB Adapter","fork":true,"url":"https://api.github.com/repos/andymorris/backbone-pouch","forks_url":"https://api.github.com/repos/andymorris/backbone-pouch/forks","keys_url":"https://api.github.com/repos/andymorris/backbone-pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andymorris/backbone-pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andymorris/backbone-pouch/teams","hooks_url":"https://api.github.com/repos/andymorris/backbone-pouch/hooks","issue_events_url":"https://api.github.com/repos/andymorris/backbone-pouch/issues/events{/number}","events_url":"https://api.github.com/repos/andymorris/backbone-pouch/events","assignees_url":"https://api.github.com/repos/andymorris/backbone-pouch/assignees{/user}","branches_url":"https://api.github.com/repos/andymorris/backbone-pouch/branches{/branch}","tags_url":"https://api.github.com/repos/andymorris/backbone-pouch/tags","blobs_url":"https://api.github.com/repos/andymorris/backbone-pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andymorris/backbone-pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andymorris/backbone-pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/andymorris/backbone-pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andymorris/backbone-pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/andymorris/backbone-pouch/languages","stargazers_url":"https://api.github.com/repos/andymorris/backbone-pouch/stargazers","contributors_url":"https://api.github.com/repos/andymorris/backbone-pouch/contributors","subscribers_url":"https://api.github.com/repos/andymorris/backbone-pouch/subscribers","subscription_url":"https://api.github.com/repos/andymorris/backbone-pouch/subscription","commits_url":"https://api.github.com/repos/andymorris/backbone-pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/andymorris/backbone-pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/andymorris/backbone-pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/andymorris/backbone-pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/andymorris/backbone-pouch/contents/{+path}","compare_url":"https://api.github.com/repos/andymorris/backbone-pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andymorris/backbone-pouch/merges","archive_url":"https://api.github.com/repos/andymorris/backbone-pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andymorris/backbone-pouch/downloads","issues_url":"https://api.github.com/repos/andymorris/backbone-pouch/issues{/number}","pulls_url":"https://api.github.com/repos/andymorris/backbone-pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/andymorris/backbone-pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/andymorris/backbone-pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andymorris/backbone-pouch/labels{/name}","releases_url":"https://api.github.com/repos/andymorris/backbone-pouch/releases{/id}","created_at":"2015-02-05T18:30:28Z","updated_at":"2015-02-05T18:30:29Z","pushed_at":"2015-02-26T19:19:04Z","git_url":"git://github.com/andymorris/backbone-pouch.git","ssh_url":"git@github.com:andymorris/backbone-pouch.git","clone_url":"https://github.com/andymorris/backbone-pouch.git","svn_url":"https://github.com/andymorris/backbone-pouch","homepage":"http://jo.github.io/backbone-pouch/","size":872,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jo:master","ref":"master","sha":"90414cbf94a238298fbdf9001b669eac585a33a7","user":{"login":"jo","id":17586,"avatar_url":"https://avatars.githubusercontent.com/u/17586?v=3","gravatar_id":"","url":"https://api.github.com/users/jo","html_url":"https://github.com/jo","followers_url":"https://api.github.com/users/jo/followers","following_url":"https://api.github.com/users/jo/following{/other_user}","gists_url":"https://api.github.com/users/jo/gists{/gist_id}","starred_url":"https://api.github.com/users/jo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jo/subscriptions","organizations_url":"https://api.github.com/users/jo/orgs","repos_url":"https://api.github.com/users/jo/repos","events_url":"https://api.github.com/users/jo/events{/privacy}","received_events_url":"https://api.github.com/users/jo/received_events","type":"User","site_admin":false},"repo":{"id":3960659,"name":"backbone-pouch","full_name":"jo/backbone-pouch","owner":{"login":"jo","id":17586,"avatar_url":"https://avatars.githubusercontent.com/u/17586?v=3","gravatar_id":"","url":"https://api.github.com/users/jo","html_url":"https://github.com/jo","followers_url":"https://api.github.com/users/jo/followers","following_url":"https://api.github.com/users/jo/following{/other_user}","gists_url":"https://api.github.com/users/jo/gists{/gist_id}","starred_url":"https://api.github.com/users/jo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jo/subscriptions","organizations_url":"https://api.github.com/users/jo/orgs","repos_url":"https://api.github.com/users/jo/repos","events_url":"https://api.github.com/users/jo/events{/privacy}","received_events_url":"https://api.github.com/users/jo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jo/backbone-pouch","description":"Backbone PouchDB Adapter","fork":false,"url":"https://api.github.com/repos/jo/backbone-pouch","forks_url":"https://api.github.com/repos/jo/backbone-pouch/forks","keys_url":"https://api.github.com/repos/jo/backbone-pouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jo/backbone-pouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jo/backbone-pouch/teams","hooks_url":"https://api.github.com/repos/jo/backbone-pouch/hooks","issue_events_url":"https://api.github.com/repos/jo/backbone-pouch/issues/events{/number}","events_url":"https://api.github.com/repos/jo/backbone-pouch/events","assignees_url":"https://api.github.com/repos/jo/backbone-pouch/assignees{/user}","branches_url":"https://api.github.com/repos/jo/backbone-pouch/branches{/branch}","tags_url":"https://api.github.com/repos/jo/backbone-pouch/tags","blobs_url":"https://api.github.com/repos/jo/backbone-pouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jo/backbone-pouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jo/backbone-pouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/jo/backbone-pouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jo/backbone-pouch/statuses/{sha}","languages_url":"https://api.github.com/repos/jo/backbone-pouch/languages","stargazers_url":"https://api.github.com/repos/jo/backbone-pouch/stargazers","contributors_url":"https://api.github.com/repos/jo/backbone-pouch/contributors","subscribers_url":"https://api.github.com/repos/jo/backbone-pouch/subscribers","subscription_url":"https://api.github.com/repos/jo/backbone-pouch/subscription","commits_url":"https://api.github.com/repos/jo/backbone-pouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/jo/backbone-pouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/jo/backbone-pouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/jo/backbone-pouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/jo/backbone-pouch/contents/{+path}","compare_url":"https://api.github.com/repos/jo/backbone-pouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jo/backbone-pouch/merges","archive_url":"https://api.github.com/repos/jo/backbone-pouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jo/backbone-pouch/downloads","issues_url":"https://api.github.com/repos/jo/backbone-pouch/issues{/number}","pulls_url":"https://api.github.com/repos/jo/backbone-pouch/pulls{/number}","milestones_url":"https://api.github.com/repos/jo/backbone-pouch/milestones{/number}","notifications_url":"https://api.github.com/repos/jo/backbone-pouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jo/backbone-pouch/labels{/name}","releases_url":"https://api.github.com/repos/jo/backbone-pouch/releases{/id}","created_at":"2012-04-07T21:15:43Z","updated_at":"2015-02-26T12:12:55Z","pushed_at":"2015-02-27T12:09:36Z","git_url":"git://github.com/jo/backbone-pouch.git","ssh_url":"git@github.com:jo/backbone-pouch.git","clone_url":"https://github.com/jo/backbone-pouch.git","svn_url":"https://github.com/jo/backbone-pouch","homepage":"http://jo.github.io/backbone-pouch/","size":1151,"stargazers_count":148,"watchers_count":148,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":25,"mirror_url":null,"open_issues_count":5,"forks":25,"open_issues":5,"watchers":148,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jo/backbone-pouch/pulls/37"},"html":{"href":"https://github.com/jo/backbone-pouch/pull/37"},"issue":{"href":"https://api.github.com/repos/jo/backbone-pouch/issues/37"},"comments":{"href":"https://api.github.com/repos/jo/backbone-pouch/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/jo/backbone-pouch/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/jo/backbone-pouch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jo/backbone-pouch/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/jo/backbone-pouch/statuses/056cf10b9f1278fdf76b8785a181420cdd64aac4"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"jo","id":17586,"avatar_url":"https://avatars.githubusercontent.com/u/17586?v=3","gravatar_id":"","url":"https://api.github.com/users/jo","html_url":"https://github.com/jo","followers_url":"https://api.github.com/users/jo/followers","following_url":"https://api.github.com/users/jo/following{/other_user}","gists_url":"https://api.github.com/users/jo/gists{/gist_id}","starred_url":"https://api.github.com/users/jo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jo/subscriptions","organizations_url":"https://api.github.com/users/jo/orgs","repos_url":"https://api.github.com/users/jo/repos","events_url":"https://api.github.com/users/jo/events{/privacy}","received_events_url":"https://api.github.com/users/jo/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":1,"additions":11,"deletions":11,"changed_files":1}}