{"action":"created","comment":{"url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/comments/116387807","pull_request_review_id":38005926,"id":116387807,"diff_hunk":"@@ -1,6 +1,146 @@\n require 'devise/multi_email/version'\n require 'devise'\n \n+module Devise\n+  module MultiEmail\n+\n+    def self.configure(&block)\n+      yield self\n+    end\n+\n+    def self.parent_association_name\n+      @parent_association_name ||= :user\n+    end\n+\n+    def self.parent_association_name=(name)\n+      @parent_association_name = name.try(:to_sym)\n+    end\n+\n+    def self.emails_association_name\n+      @emails_association_name ||= :emails\n+    end\n+\n+    def self.emails_association_name=(name)\n+      @emails_association_name = name.try(:to_sym)\n+    end\n+\n+    def self.primary_email_method_name\n+      @primary_email_method_name ||= :primary_email\n+    end\n+\n+    def self.primary_email_method_name=(name)\n+      @primary_email_method_name = name.try(:to_sym)\n+    end\n+\n+    module ParentModelExtensions\n+      extend ActiveSupport::Concern\n+\n+      included do\n+        _multi_email_emails_association_class.send :include, EmailModelExtensions\n+\n+        alias_method _multi_email_primary_email_method_name, :_multi_email_find_primary_email\n+      end\n+\n+      # Gets the primary email record.\n+      def _multi_email_filtered_emails\n+        _multi_email_emails_association.reject(&:destroyed?).reject(&:marked_for_destruction?)\n+      end\n+\n+      # Gets the primary email record.\n+      def _multi_email_find_primary_email\n+        _multi_email_filtered_emails.find(&:primary?)\n+      end\n+\n+      def _multi_email_change_email_to(new_email)\n+        valid_emails = _multi_email_filtered_emails\n+        formatted_email = self.class.send(:devise_parameter_filter).filter(email: new_email)[:email]\n+\n+        # mark none as primary when set to nil\n+        if new_email.nil?\n+          valid_emails.each{|record| record.primary = false}","path":"lib/devise/multi_email.rb","position":null,"original_position":60,"commit_id":"f7527ba797e90f2c2e6633c760564832100c38bb","original_commit_id":"49c0507477a65df3f5c269b64a176abb24013ab7","user":{"login":"joelvh","id":129096,"avatar_url":"https://avatars3.githubusercontent.com/u/129096?v=3","gravatar_id":"","url":"https://api.github.com/users/joelvh","html_url":"https://github.com/joelvh","followers_url":"https://api.github.com/users/joelvh/followers","following_url":"https://api.github.com/users/joelvh/following{/other_user}","gists_url":"https://api.github.com/users/joelvh/gists{/gist_id}","starred_url":"https://api.github.com/users/joelvh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelvh/subscriptions","organizations_url":"https://api.github.com/users/joelvh/orgs","repos_url":"https://api.github.com/users/joelvh/repos","events_url":"https://api.github.com/users/joelvh/events{/privacy}","received_events_url":"https://api.github.com/users/joelvh/received_events","type":"User","site_admin":false},"body":"@allenwq done","created_at":"2017-05-14T18:45:50Z","updated_at":"2017-05-14T18:45:50Z","html_url":"https://github.com/allenwq/devise-multi_email/pull/13#discussion_r116387807","pull_request_url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/comments/116387807"},"html":{"href":"https://github.com/allenwq/devise-multi_email/pull/13#discussion_r116387807"},"pull_request":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13","id":120236303,"html_url":"https://github.com/allenwq/devise-multi_email/pull/13","diff_url":"https://github.com/allenwq/devise-multi_email/pull/13.diff","patch_url":"https://github.com/allenwq/devise-multi_email/pull/13.patch","issue_url":"https://api.github.com/repos/allenwq/devise-multi_email/issues/13","number":13,"state":"open","locked":false,"title":"Configurable association names","user":{"login":"joelvh","id":129096,"avatar_url":"https://avatars3.githubusercontent.com/u/129096?v=3","gravatar_id":"","url":"https://api.github.com/users/joelvh","html_url":"https://github.com/joelvh","followers_url":"https://api.github.com/users/joelvh/followers","following_url":"https://api.github.com/users/joelvh/following{/other_user}","gists_url":"https://api.github.com/users/joelvh/gists{/gist_id}","starred_url":"https://api.github.com/users/joelvh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joelvh/subscriptions","organizations_url":"https://api.github.com/users/joelvh/orgs","repos_url":"https://api.github.com/users/joelvh/repos","events_url":"https://api.github.com/users/joelvh/events{/privacy}","received_events_url":"https://api.github.com/users/joelvh/received_events","type":"User","site_admin":false},"body":"You can specify whether you want to use `Email#user` and `User#emails` or change those association names.","created_at":"2017-05-12T02:11:06Z","updated_at":"2017-05-14T18:45:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"924e973bb35d7363169b76d7dc46ef966b90b266","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13/commits","review_comments_url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13/comments","review_comment_url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allenwq/devise-multi_email/issues/13/comments","statuses_url":"https://api.github.com/repos/allenwq/devise-multi_email/statuses/f7527ba797e90f2c2e6633c760564832100c38bb","head":{"label":"identification-io:feature/configurable_association_names","ref":"feature/configurable_association_names","sha":"f7527ba797e90f2c2e6633c760564832100c38bb","user":{"login":"identification-io","id":14473970,"avatar_url":"https://avatars1.githubusercontent.com/u/14473970?v=3","gravatar_id":"","url":"https://api.github.com/users/identification-io","html_url":"https://github.com/identification-io","followers_url":"https://api.github.com/users/identification-io/followers","following_url":"https://api.github.com/users/identification-io/following{/other_user}","gists_url":"https://api.github.com/users/identification-io/gists{/gist_id}","starred_url":"https://api.github.com/users/identification-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/identification-io/subscriptions","organizations_url":"https://api.github.com/users/identification-io/orgs","repos_url":"https://api.github.com/users/identification-io/repos","events_url":"https://api.github.com/users/identification-io/events{/privacy}","received_events_url":"https://api.github.com/users/identification-io/received_events","type":"Organization","site_admin":false},"repo":{"id":91037372,"name":"devise-multi_email","full_name":"identification-io/devise-multi_email","owner":{"login":"identification-io","id":14473970,"avatar_url":"https://avatars1.githubusercontent.com/u/14473970?v=3","gravatar_id":"","url":"https://api.github.com/users/identification-io","html_url":"https://github.com/identification-io","followers_url":"https://api.github.com/users/identification-io/followers","following_url":"https://api.github.com/users/identification-io/following{/other_user}","gists_url":"https://api.github.com/users/identification-io/gists{/gist_id}","starred_url":"https://api.github.com/users/identification-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/identification-io/subscriptions","organizations_url":"https://api.github.com/users/identification-io/orgs","repos_url":"https://api.github.com/users/identification-io/repos","events_url":"https://api.github.com/users/identification-io/events{/privacy}","received_events_url":"https://api.github.com/users/identification-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/identification-io/devise-multi_email","description":"✉️ Let devise support multiple emails (authenticatable, confirmable and validatable).","fork":true,"url":"https://api.github.com/repos/identification-io/devise-multi_email","forks_url":"https://api.github.com/repos/identification-io/devise-multi_email/forks","keys_url":"https://api.github.com/repos/identification-io/devise-multi_email/keys{/key_id}","collaborators_url":"https://api.github.com/repos/identification-io/devise-multi_email/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/identification-io/devise-multi_email/teams","hooks_url":"https://api.github.com/repos/identification-io/devise-multi_email/hooks","issue_events_url":"https://api.github.com/repos/identification-io/devise-multi_email/issues/events{/number}","events_url":"https://api.github.com/repos/identification-io/devise-multi_email/events","assignees_url":"https://api.github.com/repos/identification-io/devise-multi_email/assignees{/user}","branches_url":"https://api.github.com/repos/identification-io/devise-multi_email/branches{/branch}","tags_url":"https://api.github.com/repos/identification-io/devise-multi_email/tags","blobs_url":"https://api.github.com/repos/identification-io/devise-multi_email/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/identification-io/devise-multi_email/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/identification-io/devise-multi_email/git/refs{/sha}","trees_url":"https://api.github.com/repos/identification-io/devise-multi_email/git/trees{/sha}","statuses_url":"https://api.github.com/repos/identification-io/devise-multi_email/statuses/{sha}","languages_url":"https://api.github.com/repos/identification-io/devise-multi_email/languages","stargazers_url":"https://api.github.com/repos/identification-io/devise-multi_email/stargazers","contributors_url":"https://api.github.com/repos/identification-io/devise-multi_email/contributors","subscribers_url":"https://api.github.com/repos/identification-io/devise-multi_email/subscribers","subscription_url":"https://api.github.com/repos/identification-io/devise-multi_email/subscription","commits_url":"https://api.github.com/repos/identification-io/devise-multi_email/commits{/sha}","git_commits_url":"https://api.github.com/repos/identification-io/devise-multi_email/git/commits{/sha}","comments_url":"https://api.github.com/repos/identification-io/devise-multi_email/comments{/number}","issue_comment_url":"https://api.github.com/repos/identification-io/devise-multi_email/issues/comments{/number}","contents_url":"https://api.github.com/repos/identification-io/devise-multi_email/contents/{+path}","compare_url":"https://api.github.com/repos/identification-io/devise-multi_email/compare/{base}...{head}","merges_url":"https://api.github.com/repos/identification-io/devise-multi_email/merges","archive_url":"https://api.github.com/repos/identification-io/devise-multi_email/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/identification-io/devise-multi_email/downloads","issues_url":"https://api.github.com/repos/identification-io/devise-multi_email/issues{/number}","pulls_url":"https://api.github.com/repos/identification-io/devise-multi_email/pulls{/number}","milestones_url":"https://api.github.com/repos/identification-io/devise-multi_email/milestones{/number}","notifications_url":"https://api.github.com/repos/identification-io/devise-multi_email/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/identification-io/devise-multi_email/labels{/name}","releases_url":"https://api.github.com/repos/identification-io/devise-multi_email/releases{/id}","deployments_url":"https://api.github.com/repos/identification-io/devise-multi_email/deployments","created_at":"2017-05-12T01:15:10Z","updated_at":"2017-05-12T01:15:11Z","pushed_at":"2017-05-14T18:44:52Z","git_url":"git://github.com/identification-io/devise-multi_email.git","ssh_url":"git@github.com:identification-io/devise-multi_email.git","clone_url":"https://github.com/identification-io/devise-multi_email.git","svn_url":"https://github.com/identification-io/devise-multi_email","homepage":"","size":110,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"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":"allenwq:master","ref":"master","sha":"b2548520498ebd3270d378554bd73202a3e224f2","user":{"login":"allenwq","id":4983239,"avatar_url":"https://avatars1.githubusercontent.com/u/4983239?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwq","html_url":"https://github.com/allenwq","followers_url":"https://api.github.com/users/allenwq/followers","following_url":"https://api.github.com/users/allenwq/following{/other_user}","gists_url":"https://api.github.com/users/allenwq/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwq/subscriptions","organizations_url":"https://api.github.com/users/allenwq/orgs","repos_url":"https://api.github.com/users/allenwq/repos","events_url":"https://api.github.com/users/allenwq/events{/privacy}","received_events_url":"https://api.github.com/users/allenwq/received_events","type":"User","site_admin":false},"repo":{"id":48675849,"name":"devise-multi_email","full_name":"allenwq/devise-multi_email","owner":{"login":"allenwq","id":4983239,"avatar_url":"https://avatars1.githubusercontent.com/u/4983239?v=3","gravatar_id":"","url":"https://api.github.com/users/allenwq","html_url":"https://github.com/allenwq","followers_url":"https://api.github.com/users/allenwq/followers","following_url":"https://api.github.com/users/allenwq/following{/other_user}","gists_url":"https://api.github.com/users/allenwq/gists{/gist_id}","starred_url":"https://api.github.com/users/allenwq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenwq/subscriptions","organizations_url":"https://api.github.com/users/allenwq/orgs","repos_url":"https://api.github.com/users/allenwq/repos","events_url":"https://api.github.com/users/allenwq/events{/privacy}","received_events_url":"https://api.github.com/users/allenwq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/allenwq/devise-multi_email","description":"✉️ Let devise support multiple emails (authenticatable, confirmable and validatable).","fork":false,"url":"https://api.github.com/repos/allenwq/devise-multi_email","forks_url":"https://api.github.com/repos/allenwq/devise-multi_email/forks","keys_url":"https://api.github.com/repos/allenwq/devise-multi_email/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allenwq/devise-multi_email/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allenwq/devise-multi_email/teams","hooks_url":"https://api.github.com/repos/allenwq/devise-multi_email/hooks","issue_events_url":"https://api.github.com/repos/allenwq/devise-multi_email/issues/events{/number}","events_url":"https://api.github.com/repos/allenwq/devise-multi_email/events","assignees_url":"https://api.github.com/repos/allenwq/devise-multi_email/assignees{/user}","branches_url":"https://api.github.com/repos/allenwq/devise-multi_email/branches{/branch}","tags_url":"https://api.github.com/repos/allenwq/devise-multi_email/tags","blobs_url":"https://api.github.com/repos/allenwq/devise-multi_email/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allenwq/devise-multi_email/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allenwq/devise-multi_email/git/refs{/sha}","trees_url":"https://api.github.com/repos/allenwq/devise-multi_email/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allenwq/devise-multi_email/statuses/{sha}","languages_url":"https://api.github.com/repos/allenwq/devise-multi_email/languages","stargazers_url":"https://api.github.com/repos/allenwq/devise-multi_email/stargazers","contributors_url":"https://api.github.com/repos/allenwq/devise-multi_email/contributors","subscribers_url":"https://api.github.com/repos/allenwq/devise-multi_email/subscribers","subscription_url":"https://api.github.com/repos/allenwq/devise-multi_email/subscription","commits_url":"https://api.github.com/repos/allenwq/devise-multi_email/commits{/sha}","git_commits_url":"https://api.github.com/repos/allenwq/devise-multi_email/git/commits{/sha}","comments_url":"https://api.github.com/repos/allenwq/devise-multi_email/comments{/number}","issue_comment_url":"https://api.github.com/repos/allenwq/devise-multi_email/issues/comments{/number}","contents_url":"https://api.github.com/repos/allenwq/devise-multi_email/contents/{+path}","compare_url":"https://api.github.com/repos/allenwq/devise-multi_email/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allenwq/devise-multi_email/merges","archive_url":"https://api.github.com/repos/allenwq/devise-multi_email/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allenwq/devise-multi_email/downloads","issues_url":"https://api.github.com/repos/allenwq/devise-multi_email/issues{/number}","pulls_url":"https://api.github.com/repos/allenwq/devise-multi_email/pulls{/number}","milestones_url":"https://api.github.com/repos/allenwq/devise-multi_email/milestones{/number}","notifications_url":"https://api.github.com/repos/allenwq/devise-multi_email/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allenwq/devise-multi_email/labels{/name}","releases_url":"https://api.github.com/repos/allenwq/devise-multi_email/releases{/id}","deployments_url":"https://api.github.com/repos/allenwq/devise-multi_email/deployments","created_at":"2015-12-28T05:37:55Z","updated_at":"2017-05-11T22:53:43Z","pushed_at":"2017-05-14T18:44:34Z","git_url":"git://github.com/allenwq/devise-multi_email.git","ssh_url":"git@github.com:allenwq/devise-multi_email.git","clone_url":"https://github.com/allenwq/devise-multi_email.git","svn_url":"https://github.com/allenwq/devise-multi_email","homepage":"","size":95,"stargazers_count":18,"watchers_count":18,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":2,"forks":6,"open_issues":2,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13"},"html":{"href":"https://github.com/allenwq/devise-multi_email/pull/13"},"issue":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/issues/13"},"comments":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/allenwq/devise-multi_email/statuses/f7527ba797e90f2c2e6633c760564832100c38bb"}}}}
{"actor":{"display_login":"joelvh"}}