{"action":"opened","number":41,"pull_request":{"url":"https://api.github.com/repos/gamache/hyperresource/pulls/41","id":51072535,"html_url":"https://github.com/gamache/hyperresource/pull/41","diff_url":"https://github.com/gamache/hyperresource/pull/41.diff","patch_url":"https://github.com/gamache/hyperresource/pull/41.patch","issue_url":"https://api.github.com/repos/gamache/hyperresource/issues/41","number":41,"state":"open","locked":false,"title":"fix attribute_setter in case nil value & do not overwrite resource href with nil","user":{"login":"pvmeerbe","id":701732,"avatar_url":"https://avatars.githubusercontent.com/u/701732?v=3","gravatar_id":"","url":"https://api.github.com/users/pvmeerbe","html_url":"https://github.com/pvmeerbe","followers_url":"https://api.github.com/users/pvmeerbe/followers","following_url":"https://api.github.com/users/pvmeerbe/following{/other_user}","gists_url":"https://api.github.com/users/pvmeerbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pvmeerbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvmeerbe/subscriptions","organizations_url":"https://api.github.com/users/pvmeerbe/orgs","repos_url":"https://api.github.com/users/pvmeerbe/repos","events_url":"https://api.github.com/users/pvmeerbe/events{/privacy}","received_events_url":"https://api.github.com/users/pvmeerbe/received_events","type":"User","site_admin":false},"body":"First case: attribute-setter\r\n----------------------------\r\nImagine JSON response with an attribute set to nil --> previous code did not allow to modify this attribute in the HyperResource object due to failing method missing call\r\n\r\n--> fixed + added test case\r\n\r\nSecond case: href already set\r\n----------------------------\r\nI encountered this while trying to build a new Hyperresource object from scratch  (idea is to mimick Hyperresource::MyObject.new call, populate it with Form field data & then post it to the server)\r\n\r\npseudo code:\r\n\r\nmy_client = HyperResource.new(root: http://whatever/api)\r\nmy_client.new_from(resource: my_client, href: 'koekoek', body: {'_data_type' => 'MyObject','koekoek' =>  nil, 'blabla' =>  nil})\r\n\r\nThis will:\r\n1. create a new HyperResource object HyperResource::MyObject using resource & href\r\n2. call adapter.apply to populate it with the body data\r\n\r\nThe current code overwrites the existing href with nil as no self ref is present in body\r\nThe provided solution avoids this","created_at":"2015-11-18T11:28:21Z","updated_at":"2015-11-18T11:28:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gamache/hyperresource/pulls/41/commits","review_comments_url":"https://api.github.com/repos/gamache/hyperresource/pulls/41/comments","review_comment_url":"https://api.github.com/repos/gamache/hyperresource/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gamache/hyperresource/issues/41/comments","statuses_url":"https://api.github.com/repos/gamache/hyperresource/statuses/47d694de7a3a36b1e93e659d76b85b57ccff23f0","head":{"label":"pvmeerbe:master","ref":"master","sha":"47d694de7a3a36b1e93e659d76b85b57ccff23f0","user":{"login":"pvmeerbe","id":701732,"avatar_url":"https://avatars.githubusercontent.com/u/701732?v=3","gravatar_id":"","url":"https://api.github.com/users/pvmeerbe","html_url":"https://github.com/pvmeerbe","followers_url":"https://api.github.com/users/pvmeerbe/followers","following_url":"https://api.github.com/users/pvmeerbe/following{/other_user}","gists_url":"https://api.github.com/users/pvmeerbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pvmeerbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvmeerbe/subscriptions","organizations_url":"https://api.github.com/users/pvmeerbe/orgs","repos_url":"https://api.github.com/users/pvmeerbe/repos","events_url":"https://api.github.com/users/pvmeerbe/events{/privacy}","received_events_url":"https://api.github.com/users/pvmeerbe/received_events","type":"User","site_admin":false},"repo":{"id":43884307,"name":"hyperresource","full_name":"pvmeerbe/hyperresource","owner":{"login":"pvmeerbe","id":701732,"avatar_url":"https://avatars.githubusercontent.com/u/701732?v=3","gravatar_id":"","url":"https://api.github.com/users/pvmeerbe","html_url":"https://github.com/pvmeerbe","followers_url":"https://api.github.com/users/pvmeerbe/followers","following_url":"https://api.github.com/users/pvmeerbe/following{/other_user}","gists_url":"https://api.github.com/users/pvmeerbe/gists{/gist_id}","starred_url":"https://api.github.com/users/pvmeerbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvmeerbe/subscriptions","organizations_url":"https://api.github.com/users/pvmeerbe/orgs","repos_url":"https://api.github.com/users/pvmeerbe/repos","events_url":"https://api.github.com/users/pvmeerbe/events{/privacy}","received_events_url":"https://api.github.com/users/pvmeerbe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pvmeerbe/hyperresource","description":"A self-inflating Ruby client for hypermedia APIs.","fork":true,"url":"https://api.github.com/repos/pvmeerbe/hyperresource","forks_url":"https://api.github.com/repos/pvmeerbe/hyperresource/forks","keys_url":"https://api.github.com/repos/pvmeerbe/hyperresource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pvmeerbe/hyperresource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pvmeerbe/hyperresource/teams","hooks_url":"https://api.github.com/repos/pvmeerbe/hyperresource/hooks","issue_events_url":"https://api.github.com/repos/pvmeerbe/hyperresource/issues/events{/number}","events_url":"https://api.github.com/repos/pvmeerbe/hyperresource/events","assignees_url":"https://api.github.com/repos/pvmeerbe/hyperresource/assignees{/user}","branches_url":"https://api.github.com/repos/pvmeerbe/hyperresource/branches{/branch}","tags_url":"https://api.github.com/repos/pvmeerbe/hyperresource/tags","blobs_url":"https://api.github.com/repos/pvmeerbe/hyperresource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pvmeerbe/hyperresource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pvmeerbe/hyperresource/git/refs{/sha}","trees_url":"https://api.github.com/repos/pvmeerbe/hyperresource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pvmeerbe/hyperresource/statuses/{sha}","languages_url":"https://api.github.com/repos/pvmeerbe/hyperresource/languages","stargazers_url":"https://api.github.com/repos/pvmeerbe/hyperresource/stargazers","contributors_url":"https://api.github.com/repos/pvmeerbe/hyperresource/contributors","subscribers_url":"https://api.github.com/repos/pvmeerbe/hyperresource/subscribers","subscription_url":"https://api.github.com/repos/pvmeerbe/hyperresource/subscription","commits_url":"https://api.github.com/repos/pvmeerbe/hyperresource/commits{/sha}","git_commits_url":"https://api.github.com/repos/pvmeerbe/hyperresource/git/commits{/sha}","comments_url":"https://api.github.com/repos/pvmeerbe/hyperresource/comments{/number}","issue_comment_url":"https://api.github.com/repos/pvmeerbe/hyperresource/issues/comments{/number}","contents_url":"https://api.github.com/repos/pvmeerbe/hyperresource/contents/{+path}","compare_url":"https://api.github.com/repos/pvmeerbe/hyperresource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pvmeerbe/hyperresource/merges","archive_url":"https://api.github.com/repos/pvmeerbe/hyperresource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pvmeerbe/hyperresource/downloads","issues_url":"https://api.github.com/repos/pvmeerbe/hyperresource/issues{/number}","pulls_url":"https://api.github.com/repos/pvmeerbe/hyperresource/pulls{/number}","milestones_url":"https://api.github.com/repos/pvmeerbe/hyperresource/milestones{/number}","notifications_url":"https://api.github.com/repos/pvmeerbe/hyperresource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pvmeerbe/hyperresource/labels{/name}","releases_url":"https://api.github.com/repos/pvmeerbe/hyperresource/releases{/id}","created_at":"2015-10-08T11:37:05Z","updated_at":"2015-10-08T11:37:06Z","pushed_at":"2015-11-18T11:26:36Z","git_url":"git://github.com/pvmeerbe/hyperresource.git","ssh_url":"git@github.com:pvmeerbe/hyperresource.git","clone_url":"https://github.com/pvmeerbe/hyperresource.git","svn_url":"https://github.com/pvmeerbe/hyperresource","homepage":"http://hyperresource.com/doc","size":397,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gamache:master","ref":"master","sha":"9e107b9b694214f1734d1f632d752aa4a4d948f1","user":{"login":"gamache","id":45100,"avatar_url":"https://avatars.githubusercontent.com/u/45100?v=3","gravatar_id":"","url":"https://api.github.com/users/gamache","html_url":"https://github.com/gamache","followers_url":"https://api.github.com/users/gamache/followers","following_url":"https://api.github.com/users/gamache/following{/other_user}","gists_url":"https://api.github.com/users/gamache/gists{/gist_id}","starred_url":"https://api.github.com/users/gamache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamache/subscriptions","organizations_url":"https://api.github.com/users/gamache/orgs","repos_url":"https://api.github.com/users/gamache/repos","events_url":"https://api.github.com/users/gamache/events{/privacy}","received_events_url":"https://api.github.com/users/gamache/received_events","type":"User","site_admin":false},"repo":{"id":8640029,"name":"hyperresource","full_name":"gamache/hyperresource","owner":{"login":"gamache","id":45100,"avatar_url":"https://avatars.githubusercontent.com/u/45100?v=3","gravatar_id":"","url":"https://api.github.com/users/gamache","html_url":"https://github.com/gamache","followers_url":"https://api.github.com/users/gamache/followers","following_url":"https://api.github.com/users/gamache/following{/other_user}","gists_url":"https://api.github.com/users/gamache/gists{/gist_id}","starred_url":"https://api.github.com/users/gamache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gamache/subscriptions","organizations_url":"https://api.github.com/users/gamache/orgs","repos_url":"https://api.github.com/users/gamache/repos","events_url":"https://api.github.com/users/gamache/events{/privacy}","received_events_url":"https://api.github.com/users/gamache/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gamache/hyperresource","description":"A self-inflating Ruby client for hypermedia APIs.","fork":false,"url":"https://api.github.com/repos/gamache/hyperresource","forks_url":"https://api.github.com/repos/gamache/hyperresource/forks","keys_url":"https://api.github.com/repos/gamache/hyperresource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gamache/hyperresource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gamache/hyperresource/teams","hooks_url":"https://api.github.com/repos/gamache/hyperresource/hooks","issue_events_url":"https://api.github.com/repos/gamache/hyperresource/issues/events{/number}","events_url":"https://api.github.com/repos/gamache/hyperresource/events","assignees_url":"https://api.github.com/repos/gamache/hyperresource/assignees{/user}","branches_url":"https://api.github.com/repos/gamache/hyperresource/branches{/branch}","tags_url":"https://api.github.com/repos/gamache/hyperresource/tags","blobs_url":"https://api.github.com/repos/gamache/hyperresource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gamache/hyperresource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gamache/hyperresource/git/refs{/sha}","trees_url":"https://api.github.com/repos/gamache/hyperresource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gamache/hyperresource/statuses/{sha}","languages_url":"https://api.github.com/repos/gamache/hyperresource/languages","stargazers_url":"https://api.github.com/repos/gamache/hyperresource/stargazers","contributors_url":"https://api.github.com/repos/gamache/hyperresource/contributors","subscribers_url":"https://api.github.com/repos/gamache/hyperresource/subscribers","subscription_url":"https://api.github.com/repos/gamache/hyperresource/subscription","commits_url":"https://api.github.com/repos/gamache/hyperresource/commits{/sha}","git_commits_url":"https://api.github.com/repos/gamache/hyperresource/git/commits{/sha}","comments_url":"https://api.github.com/repos/gamache/hyperresource/comments{/number}","issue_comment_url":"https://api.github.com/repos/gamache/hyperresource/issues/comments{/number}","contents_url":"https://api.github.com/repos/gamache/hyperresource/contents/{+path}","compare_url":"https://api.github.com/repos/gamache/hyperresource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gamache/hyperresource/merges","archive_url":"https://api.github.com/repos/gamache/hyperresource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gamache/hyperresource/downloads","issues_url":"https://api.github.com/repos/gamache/hyperresource/issues{/number}","pulls_url":"https://api.github.com/repos/gamache/hyperresource/pulls{/number}","milestones_url":"https://api.github.com/repos/gamache/hyperresource/milestones{/number}","notifications_url":"https://api.github.com/repos/gamache/hyperresource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gamache/hyperresource/labels{/name}","releases_url":"https://api.github.com/repos/gamache/hyperresource/releases{/id}","created_at":"2013-03-08T00:47:41Z","updated_at":"2015-11-18T10:19:25Z","pushed_at":"2015-11-02T18:55:13Z","git_url":"git://github.com/gamache/hyperresource.git","ssh_url":"git@github.com:gamache/hyperresource.git","clone_url":"https://github.com/gamache/hyperresource.git","svn_url":"https://github.com/gamache/hyperresource","homepage":"http://hyperresource.com/doc","size":1100,"stargazers_count":305,"watchers_count":305,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":10,"forks":31,"open_issues":10,"watchers":305,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gamache/hyperresource/pulls/41"},"html":{"href":"https://github.com/gamache/hyperresource/pull/41"},"issue":{"href":"https://api.github.com/repos/gamache/hyperresource/issues/41"},"comments":{"href":"https://api.github.com/repos/gamache/hyperresource/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/gamache/hyperresource/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/gamache/hyperresource/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gamache/hyperresource/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/gamache/hyperresource/statuses/47d694de7a3a36b1e93e659d76b85b57ccff23f0"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":8,"deletions":2,"changed_files":3}}