{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/63824606","id":63824606,"diff_hunk":"@@ -0,0 +1,64 @@\n+require 'active_support/core_ext/hash/keys'\n+\n+module ActiveModel\n+  module AttributeAssignment\n+    include ActiveModel::ForbiddenAttributesProtection\n+\n+    # Allows you to set all the attributes by passing in a hash of attributes with\n+    # keys matching the attribute names.\n+    #\n+    # If the passed hash responds to <tt>permitted?</tt> method and the return value\n+    # of this method is +false+ an <tt>ActiveModel::ForbiddenAttributesError</tt>\n+    # exception is raised.\n+    #\n+    #   class Cat\n+    #     include ActiveModel::AttributeAssignment\n+    #     attr_accessor :name, :status\n+    #   end\n+    #\n+    #   cat = Cat.new\n+    #   cat.assign_attributes(name: \"Gorby\", status: \"yawning\")\n+    #   cat.name # => 'Gorby'\n+    #   cate.status => 'yawning'\n+    #   cat.assign_attributes(status: \"sleeping\")\n+    #   cat.name # => 'Gorby'\n+    #   cat.status => 'sleeping'\n+    def assign_attributes(new_attributes)\n+      if !new_attributes.respond_to?(:stringify_keys)","path":"activemodel/lib/active_model/attribute_assignment.rb","position":27,"original_position":27,"commit_id":"2606fb339797a99c50e531105fc92071cef3db01","original_commit_id":"f39d770e587e22137227f7950a548f6d2bcaaa41","user":{"login":"PikachuEXE","id":1018543,"avatar_url":"https://avatars.githubusercontent.com/u/1018543?v=3","gravatar_id":"","url":"https://api.github.com/users/PikachuEXE","html_url":"https://github.com/PikachuEXE","followers_url":"https://api.github.com/users/PikachuEXE/followers","following_url":"https://api.github.com/users/PikachuEXE/following{/other_user}","gists_url":"https://api.github.com/users/PikachuEXE/gists{/gist_id}","starred_url":"https://api.github.com/users/PikachuEXE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PikachuEXE/subscriptions","organizations_url":"https://api.github.com/users/PikachuEXE/orgs","repos_url":"https://api.github.com/users/PikachuEXE/repos","events_url":"https://api.github.com/users/PikachuEXE/events{/privacy}","received_events_url":"https://api.github.com/users/PikachuEXE/received_events","type":"User","site_admin":false},"body":"Why this is using `if !` instead of `unless`?","created_at":"2016-05-19T05:34:07Z","updated_at":"2016-05-19T05:34:07Z","html_url":"https://github.com/rails/rails/pull/10776#discussion_r63824606","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/10776","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/63824606"},"html":{"href":"https://github.com/rails/rails/pull/10776#discussion_r63824606"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/10776"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/10776","id":5956595,"html_url":"https://github.com/rails/rails/pull/10776","diff_url":"https://github.com/rails/rails/pull/10776.diff","patch_url":"https://github.com/rails/rails/pull/10776.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/10776","number":10776,"state":"closed","locked":false,"title":"Extracted attributes assingment from ActiveRecord to ActiveModel","user":{"login":"bogdan","id":122436,"avatar_url":"https://avatars.githubusercontent.com/u/122436?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdan","html_url":"https://github.com/bogdan","followers_url":"https://api.github.com/users/bogdan/followers","following_url":"https://api.github.com/users/bogdan/following{/other_user}","gists_url":"https://api.github.com/users/bogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdan/subscriptions","organizations_url":"https://api.github.com/users/bogdan/orgs","repos_url":"https://api.github.com/users/bogdan/repos","events_url":"https://api.github.com/users/bogdan/events{/privacy}","received_events_url":"https://api.github.com/users/bogdan/received_events","type":"User","site_admin":false},"body":"Now you are able to do:\r\n\r\n\r\n``` ruby\r\nclass Feedback\r\n  include ActiveModel::AttributeAssignment\r\n  attr_accessor :email, :subject, :body\r\nend\r\n\r\nf = Feedback.new\r\nf.assign_attributes(\r\n  :email => \"bogdan@example.com\", \r\n  :subject => \"Hello\", \r\n  :body => \"The app dont work for me\"\r\n)\r\n```\r\n\r\nThis is just a proof of concept PR.\r\n\r\nThere is still some todos:\r\n\r\n* Write tests for ActiveModel::AttributeAssignment\r\n* Deprecate AR::UnknownAttributeError in flavor of AM one\r\n* Add change log entry\r\n* rebase change log entry 2-3 times\r\n\r\nI am gonna add them if this will be approved to merge in.\r\n","created_at":"2013-05-28T07:39:05Z","updated_at":"2016-05-19T05:34:07Z","closed_at":"2015-01-23T21:55:23Z","merged_at":"2015-01-23T21:55:23Z","merge_commit_sha":"bd21cc92f31c2d57d816484d20dd376261c437fe","assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/47","html_url":"https://github.com/rails/rails/milestones/5.0.0","labels_url":"https://api.github.com/repos/rails/rails/milestones/47/labels","id":1467326,"number":47,"title":"5.0.0","description":"","creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":462,"state":"open","created_at":"2015-12-18T21:17:59Z","updated_at":"2016-05-16T21:56:50Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/rails/rails/pulls/10776/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/10776/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails/rails/issues/10776/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/2606fb339797a99c50e531105fc92071cef3db01","head":{"label":"bogdan:assign-attributes","ref":"assign-attributes","sha":"2606fb339797a99c50e531105fc92071cef3db01","user":{"login":"bogdan","id":122436,"avatar_url":"https://avatars.githubusercontent.com/u/122436?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdan","html_url":"https://github.com/bogdan","followers_url":"https://api.github.com/users/bogdan/followers","following_url":"https://api.github.com/users/bogdan/following{/other_user}","gists_url":"https://api.github.com/users/bogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdan/subscriptions","organizations_url":"https://api.github.com/users/bogdan/orgs","repos_url":"https://api.github.com/users/bogdan/repos","events_url":"https://api.github.com/users/bogdan/events{/privacy}","received_events_url":"https://api.github.com/users/bogdan/received_events","type":"User","site_admin":false},"repo":{"id":3515719,"name":"rails","full_name":"bogdan/rails","owner":{"login":"bogdan","id":122436,"avatar_url":"https://avatars.githubusercontent.com/u/122436?v=3","gravatar_id":"","url":"https://api.github.com/users/bogdan","html_url":"https://github.com/bogdan","followers_url":"https://api.github.com/users/bogdan/followers","following_url":"https://api.github.com/users/bogdan/following{/other_user}","gists_url":"https://api.github.com/users/bogdan/gists{/gist_id}","starred_url":"https://api.github.com/users/bogdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogdan/subscriptions","organizations_url":"https://api.github.com/users/bogdan/orgs","repos_url":"https://api.github.com/users/bogdan/repos","events_url":"https://api.github.com/users/bogdan/events{/privacy}","received_events_url":"https://api.github.com/users/bogdan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bogdan/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/bogdan/rails","forks_url":"https://api.github.com/repos/bogdan/rails/forks","keys_url":"https://api.github.com/repos/bogdan/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bogdan/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bogdan/rails/teams","hooks_url":"https://api.github.com/repos/bogdan/rails/hooks","issue_events_url":"https://api.github.com/repos/bogdan/rails/issues/events{/number}","events_url":"https://api.github.com/repos/bogdan/rails/events","assignees_url":"https://api.github.com/repos/bogdan/rails/assignees{/user}","branches_url":"https://api.github.com/repos/bogdan/rails/branches{/branch}","tags_url":"https://api.github.com/repos/bogdan/rails/tags","blobs_url":"https://api.github.com/repos/bogdan/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bogdan/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bogdan/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/bogdan/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bogdan/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/bogdan/rails/languages","stargazers_url":"https://api.github.com/repos/bogdan/rails/stargazers","contributors_url":"https://api.github.com/repos/bogdan/rails/contributors","subscribers_url":"https://api.github.com/repos/bogdan/rails/subscribers","subscription_url":"https://api.github.com/repos/bogdan/rails/subscription","commits_url":"https://api.github.com/repos/bogdan/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/bogdan/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/bogdan/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/bogdan/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/bogdan/rails/contents/{+path}","compare_url":"https://api.github.com/repos/bogdan/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bogdan/rails/merges","archive_url":"https://api.github.com/repos/bogdan/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bogdan/rails/downloads","issues_url":"https://api.github.com/repos/bogdan/rails/issues{/number}","pulls_url":"https://api.github.com/repos/bogdan/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/bogdan/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/bogdan/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bogdan/rails/labels{/name}","releases_url":"https://api.github.com/repos/bogdan/rails/releases{/id}","deployments_url":"https://api.github.com/repos/bogdan/rails/deployments","created_at":"2012-02-22T15:18:15Z","updated_at":"2015-02-27T15:17:57Z","pushed_at":"2016-04-19T19:32:06Z","git_url":"git://github.com/bogdan/rails.git","ssh_url":"git@github.com:bogdan/rails.git","clone_url":"https://github.com/bogdan/rails.git","svn_url":"https://github.com/bogdan/rails","homepage":"http://rubyonrails.org","size":124605,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"rails:master","ref":"master","sha":"7c6f3938dee47f0932c2a1d4924adaebc25517ac","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","deployments_url":"https://api.github.com/repos/rails/rails/deployments","created_at":"2008-04-11T02:19:47Z","updated_at":"2016-05-19T04:30:54Z","pushed_at":"2016-05-19T05:14:25Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":341865,"stargazers_count":31190,"watchers_count":31190,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12648,"mirror_url":null,"open_issues_count":988,"forks":12648,"open_issues":988,"watchers":31190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/10776"},"html":{"href":"https://github.com/rails/rails/pull/10776"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/10776"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/10776/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/10776/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/10776/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/2606fb339797a99c50e531105fc92071cef3db01"}}}}