{"action":"created","comment":{"url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/comments/128174271","pull_request_review_id":50826923,"id":128174271,"diff_hunk":"@@ -96,5 +97,74 @@ defmodule Attribrutex do\n   defp select_custom_fields(query, :keys), do: from c in query, select: c.key\n   defp select_custom_fields(query, :fields), do: from c in query, select: %{key: c.key, type: c.field_type}\n \n+  @doc \"\"\"\n+  Use it to manage custom_fields on building the changesets.\n+  You can use the opts like on `list_custom_fields_for/2` to set the\n+  `context_id` and `context_type`\n+\n+  ## Example:\n+\n+    ```\n+    defmodule AttribrutexUser do\n+      use Ecto.Schema\n+      import Ecto.Changeset\n+\n+      schema \"users\" do\n+        field :email, :string\n+        field :custom_fields, :map, default: %{}\n+\n+        timestamps()\n+      end\n+\n+      def changeset(struct, params \\\\ %{}) do\n+        struct\n+        |> cast(params, [:email])\n+        |> validate_required([:email])\n+        |> Attribrutex.prepare_custom_fields(params, opts)","path":"lib/attribrutex.ex","position":35,"original_position":35,"commit_id":"44aa2212d4423f7d43de5cc0aad4e05a0b90eebd","original_commit_id":"44aa2212d4423f7d43de5cc0aad4e05a0b90eebd","user":{"login":"belaustegui","id":2965623,"avatar_url":"https://avatars3.githubusercontent.com/u/2965623?v=4","gravatar_id":"","url":"https://api.github.com/users/belaustegui","html_url":"https://github.com/belaustegui","followers_url":"https://api.github.com/users/belaustegui/followers","following_url":"https://api.github.com/users/belaustegui/following{/other_user}","gists_url":"https://api.github.com/users/belaustegui/gists{/gist_id}","starred_url":"https://api.github.com/users/belaustegui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belaustegui/subscriptions","organizations_url":"https://api.github.com/users/belaustegui/orgs","repos_url":"https://api.github.com/users/belaustegui/repos","events_url":"https://api.github.com/users/belaustegui/events{/privacy}","received_events_url":"https://api.github.com/users/belaustegui/received_events","type":"User","site_admin":false},"body":"The `opts` variable is never defined inside the function. We should either define it or remove it from the call.","created_at":"2017-07-19T07:44:10Z","updated_at":"2017-07-19T07:52:20Z","html_url":"https://github.com/bizneo/Attribrutex/pull/6#discussion_r128174271","pull_request_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/comments/128174271"},"html":{"href":"https://github.com/bizneo/Attribrutex/pull/6#discussion_r128174271"},"pull_request":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6","id":131251606,"html_url":"https://github.com/bizneo/Attribrutex/pull/6","diff_url":"https://github.com/bizneo/Attribrutex/pull/6.diff","patch_url":"https://github.com/bizneo/Attribrutex/pull/6.patch","issue_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/6","number":6,"state":"open","locked":false,"title":"Prepare custom fields","user":{"login":"itSQualL","id":15184360,"avatar_url":"https://avatars1.githubusercontent.com/u/15184360?v=4","gravatar_id":"","url":"https://api.github.com/users/itSQualL","html_url":"https://github.com/itSQualL","followers_url":"https://api.github.com/users/itSQualL/followers","following_url":"https://api.github.com/users/itSQualL/following{/other_user}","gists_url":"https://api.github.com/users/itSQualL/gists{/gist_id}","starred_url":"https://api.github.com/users/itSQualL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itSQualL/subscriptions","organizations_url":"https://api.github.com/users/itSQualL/orgs","repos_url":"https://api.github.com/users/itSQualL/repos","events_url":"https://api.github.com/users/itSQualL/events{/privacy}","received_events_url":"https://api.github.com/users/itSQualL/received_events","type":"User","site_admin":false},"body":"## What does this PR do?\r\nAdds `prepare_custom_fields/3` to manage custom fields in the changeset.\r\n\r\nThe purpose of this function is that people add the function on the changeset function on their models to automatically deal with custom_params and changeset\r\n\r\nYou can see the example here: https://github.com/bizneo/Attribrutex/pull/6/files#diff-ad98f95e92d70b31d34d23a5486af0dbR123\r\n\r\n## Should we do something before? (migrations, seeds, ...)\r\nIf you've installed the project before, please, drop the test database\r\n\r\n## Any background context you want to provide?\r\nThe `prepare_custom_fields/3` function follows the next steps:\r\n- Fetch a list of custom fields based on changeset struct module and the opts (context if it exists)\r\n- Filter the params to get only the fields that exists on the DB\r\n- Call to `Attribrutex.Changeset.put/2` to add fields to the changeset\r\n- Before add to the changeset, it need to be validated. On validation fail it will be added as an error.\r\n\r\n## Types of changes\r\n\r\n- [ ] Bug fix (non-breaking change which fixes an issue)ese\r\n- [x] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Review checklist\r\n- [ ] Code follows the code style of this project.\r\n- [ ] The changes requires a change to the documentation.\r\n- [x] The documentation has been changed accordingly.\r\n- [x] Added tests to cover changes.\r\n- [x] All new and existing tests passed.\r\n","created_at":"2017-07-19T07:13:13Z","updated_at":"2017-07-19T07:52:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6a57ac8021eb7f9524356a7384d75c4e9e788da","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6/commits","review_comments_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6/comments","review_comment_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/6/comments","statuses_url":"https://api.github.com/repos/bizneo/Attribrutex/statuses/44aa2212d4423f7d43de5cc0aad4e05a0b90eebd","head":{"label":"bizneo:prepare-custom-fields","ref":"prepare-custom-fields","sha":"44aa2212d4423f7d43de5cc0aad4e05a0b90eebd","user":{"login":"bizneo","id":15247788,"avatar_url":"https://avatars3.githubusercontent.com/u/15247788?v=4","gravatar_id":"","url":"https://api.github.com/users/bizneo","html_url":"https://github.com/bizneo","followers_url":"https://api.github.com/users/bizneo/followers","following_url":"https://api.github.com/users/bizneo/following{/other_user}","gists_url":"https://api.github.com/users/bizneo/gists{/gist_id}","starred_url":"https://api.github.com/users/bizneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizneo/subscriptions","organizations_url":"https://api.github.com/users/bizneo/orgs","repos_url":"https://api.github.com/users/bizneo/repos","events_url":"https://api.github.com/users/bizneo/events{/privacy}","received_events_url":"https://api.github.com/users/bizneo/received_events","type":"Organization","site_admin":false},"repo":{"id":96877910,"name":"Attribrutex","full_name":"bizneo/Attribrutex","owner":{"login":"bizneo","id":15247788,"avatar_url":"https://avatars3.githubusercontent.com/u/15247788?v=4","gravatar_id":"","url":"https://api.github.com/users/bizneo","html_url":"https://github.com/bizneo","followers_url":"https://api.github.com/users/bizneo/followers","following_url":"https://api.github.com/users/bizneo/following{/other_user}","gists_url":"https://api.github.com/users/bizneo/gists{/gist_id}","starred_url":"https://api.github.com/users/bizneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizneo/subscriptions","organizations_url":"https://api.github.com/users/bizneo/orgs","repos_url":"https://api.github.com/users/bizneo/repos","events_url":"https://api.github.com/users/bizneo/events{/privacy}","received_events_url":"https://api.github.com/users/bizneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bizneo/Attribrutex","description":"Configure custom fields dynamically on your Phoenix models","fork":false,"url":"https://api.github.com/repos/bizneo/Attribrutex","forks_url":"https://api.github.com/repos/bizneo/Attribrutex/forks","keys_url":"https://api.github.com/repos/bizneo/Attribrutex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bizneo/Attribrutex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bizneo/Attribrutex/teams","hooks_url":"https://api.github.com/repos/bizneo/Attribrutex/hooks","issue_events_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/events{/number}","events_url":"https://api.github.com/repos/bizneo/Attribrutex/events","assignees_url":"https://api.github.com/repos/bizneo/Attribrutex/assignees{/user}","branches_url":"https://api.github.com/repos/bizneo/Attribrutex/branches{/branch}","tags_url":"https://api.github.com/repos/bizneo/Attribrutex/tags","blobs_url":"https://api.github.com/repos/bizneo/Attribrutex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bizneo/Attribrutex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bizneo/Attribrutex/git/refs{/sha}","trees_url":"https://api.github.com/repos/bizneo/Attribrutex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bizneo/Attribrutex/statuses/{sha}","languages_url":"https://api.github.com/repos/bizneo/Attribrutex/languages","stargazers_url":"https://api.github.com/repos/bizneo/Attribrutex/stargazers","contributors_url":"https://api.github.com/repos/bizneo/Attribrutex/contributors","subscribers_url":"https://api.github.com/repos/bizneo/Attribrutex/subscribers","subscription_url":"https://api.github.com/repos/bizneo/Attribrutex/subscription","commits_url":"https://api.github.com/repos/bizneo/Attribrutex/commits{/sha}","git_commits_url":"https://api.github.com/repos/bizneo/Attribrutex/git/commits{/sha}","comments_url":"https://api.github.com/repos/bizneo/Attribrutex/comments{/number}","issue_comment_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/comments{/number}","contents_url":"https://api.github.com/repos/bizneo/Attribrutex/contents/{+path}","compare_url":"https://api.github.com/repos/bizneo/Attribrutex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bizneo/Attribrutex/merges","archive_url":"https://api.github.com/repos/bizneo/Attribrutex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bizneo/Attribrutex/downloads","issues_url":"https://api.github.com/repos/bizneo/Attribrutex/issues{/number}","pulls_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls{/number}","milestones_url":"https://api.github.com/repos/bizneo/Attribrutex/milestones{/number}","notifications_url":"https://api.github.com/repos/bizneo/Attribrutex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bizneo/Attribrutex/labels{/name}","releases_url":"https://api.github.com/repos/bizneo/Attribrutex/releases{/id}","deployments_url":"https://api.github.com/repos/bizneo/Attribrutex/deployments","created_at":"2017-07-11T09:49:08Z","updated_at":"2017-07-11T10:02:07Z","pushed_at":"2017-07-19T07:24:58Z","git_url":"git://github.com/bizneo/Attribrutex.git","ssh_url":"git@github.com:bizneo/Attribrutex.git","clone_url":"https://github.com/bizneo/Attribrutex.git","svn_url":"https://github.com/bizneo/Attribrutex","homepage":"","size":41,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"bizneo:master","ref":"master","sha":"8df422e76997dc4fc35d4eec29591d94b0fb5a3c","user":{"login":"bizneo","id":15247788,"avatar_url":"https://avatars3.githubusercontent.com/u/15247788?v=4","gravatar_id":"","url":"https://api.github.com/users/bizneo","html_url":"https://github.com/bizneo","followers_url":"https://api.github.com/users/bizneo/followers","following_url":"https://api.github.com/users/bizneo/following{/other_user}","gists_url":"https://api.github.com/users/bizneo/gists{/gist_id}","starred_url":"https://api.github.com/users/bizneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizneo/subscriptions","organizations_url":"https://api.github.com/users/bizneo/orgs","repos_url":"https://api.github.com/users/bizneo/repos","events_url":"https://api.github.com/users/bizneo/events{/privacy}","received_events_url":"https://api.github.com/users/bizneo/received_events","type":"Organization","site_admin":false},"repo":{"id":96877910,"name":"Attribrutex","full_name":"bizneo/Attribrutex","owner":{"login":"bizneo","id":15247788,"avatar_url":"https://avatars3.githubusercontent.com/u/15247788?v=4","gravatar_id":"","url":"https://api.github.com/users/bizneo","html_url":"https://github.com/bizneo","followers_url":"https://api.github.com/users/bizneo/followers","following_url":"https://api.github.com/users/bizneo/following{/other_user}","gists_url":"https://api.github.com/users/bizneo/gists{/gist_id}","starred_url":"https://api.github.com/users/bizneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizneo/subscriptions","organizations_url":"https://api.github.com/users/bizneo/orgs","repos_url":"https://api.github.com/users/bizneo/repos","events_url":"https://api.github.com/users/bizneo/events{/privacy}","received_events_url":"https://api.github.com/users/bizneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bizneo/Attribrutex","description":"Configure custom fields dynamically on your Phoenix models","fork":false,"url":"https://api.github.com/repos/bizneo/Attribrutex","forks_url":"https://api.github.com/repos/bizneo/Attribrutex/forks","keys_url":"https://api.github.com/repos/bizneo/Attribrutex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bizneo/Attribrutex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bizneo/Attribrutex/teams","hooks_url":"https://api.github.com/repos/bizneo/Attribrutex/hooks","issue_events_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/events{/number}","events_url":"https://api.github.com/repos/bizneo/Attribrutex/events","assignees_url":"https://api.github.com/repos/bizneo/Attribrutex/assignees{/user}","branches_url":"https://api.github.com/repos/bizneo/Attribrutex/branches{/branch}","tags_url":"https://api.github.com/repos/bizneo/Attribrutex/tags","blobs_url":"https://api.github.com/repos/bizneo/Attribrutex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bizneo/Attribrutex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bizneo/Attribrutex/git/refs{/sha}","trees_url":"https://api.github.com/repos/bizneo/Attribrutex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bizneo/Attribrutex/statuses/{sha}","languages_url":"https://api.github.com/repos/bizneo/Attribrutex/languages","stargazers_url":"https://api.github.com/repos/bizneo/Attribrutex/stargazers","contributors_url":"https://api.github.com/repos/bizneo/Attribrutex/contributors","subscribers_url":"https://api.github.com/repos/bizneo/Attribrutex/subscribers","subscription_url":"https://api.github.com/repos/bizneo/Attribrutex/subscription","commits_url":"https://api.github.com/repos/bizneo/Attribrutex/commits{/sha}","git_commits_url":"https://api.github.com/repos/bizneo/Attribrutex/git/commits{/sha}","comments_url":"https://api.github.com/repos/bizneo/Attribrutex/comments{/number}","issue_comment_url":"https://api.github.com/repos/bizneo/Attribrutex/issues/comments{/number}","contents_url":"https://api.github.com/repos/bizneo/Attribrutex/contents/{+path}","compare_url":"https://api.github.com/repos/bizneo/Attribrutex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bizneo/Attribrutex/merges","archive_url":"https://api.github.com/repos/bizneo/Attribrutex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bizneo/Attribrutex/downloads","issues_url":"https://api.github.com/repos/bizneo/Attribrutex/issues{/number}","pulls_url":"https://api.github.com/repos/bizneo/Attribrutex/pulls{/number}","milestones_url":"https://api.github.com/repos/bizneo/Attribrutex/milestones{/number}","notifications_url":"https://api.github.com/repos/bizneo/Attribrutex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bizneo/Attribrutex/labels{/name}","releases_url":"https://api.github.com/repos/bizneo/Attribrutex/releases{/id}","deployments_url":"https://api.github.com/repos/bizneo/Attribrutex/deployments","created_at":"2017-07-11T09:49:08Z","updated_at":"2017-07-11T10:02:07Z","pushed_at":"2017-07-19T07:24:58Z","git_url":"git://github.com/bizneo/Attribrutex.git","ssh_url":"git@github.com:bizneo/Attribrutex.git","clone_url":"https://github.com/bizneo/Attribrutex.git","svn_url":"https://github.com/bizneo/Attribrutex","homepage":"","size":41,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6"},"html":{"href":"https://github.com/bizneo/Attribrutex/pull/6"},"issue":{"href":"https://api.github.com/repos/bizneo/Attribrutex/issues/6"},"comments":{"href":"https://api.github.com/repos/bizneo/Attribrutex/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bizneo/Attribrutex/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/bizneo/Attribrutex/statuses/44aa2212d4423f7d43de5cc0aad4e05a0b90eebd"}}}}
{"actor":{"display_login":"belaustegui"}}