{"action":"created","comment":{"url":"https://api.github.com/repos/yershovkiril/store/pulls/comments/73215138","id":73215138,"diff_hunk":"@@ -0,0 +1,91 @@\n+class CheckoutForm\n+  include ActiveModel::Model\n+\n+  attr_accessor :order,\n+                :step,\n+                :use_billing,\n+                :shipment_id,\n+                :billing_address_attributes,\n+                :shipping_address_attributes,\n+                :credit_card_attributes\n+\n+  validate :create_errors\n+\n+  def billing_address\n+    order.billing_address ||= order.user.try(:billing_address) || Address.new\n+  end\n+\n+  def shipping_address\n+    order.shipping_address ||= order.user.try(:shipping_address) || Address.new\n+  end\n+\n+  def credit_card\n+    order.credit_card ||= CreditCard.new\n+  end\n+\n+  def save\n+    action_by_step\n+    return false unless valid?\n+    save_by_step\n+    order.save\n+  end\n+\n+  private\n+\n+  def action_by_step\n+    case step\n+    when :address then bind_address\n+    when :delivery then bind_delivery\n+    when :payment then bind_payment\n+    end\n+  end\n+\n+  def save_by_step\n+    case step\n+    when :address then shipping_address.save && billing_address.save","path":"app/forms/checkout_form.rb","position":null,"original_position":45,"commit_id":"afde7ff54f031d9dcc5df767a201fe131d258766","original_commit_id":"c6c8a947379d5f12eebdbb48f126409df75a0787","user":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"body":"done","created_at":"2016-08-02T18:52:23Z","updated_at":"2016-08-02T18:52:23Z","html_url":"https://github.com/yershovkiril/store/pull/1#discussion_r73215138","pull_request_url":"https://api.github.com/repos/yershovkiril/store/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/yershovkiril/store/pulls/comments/73215138"},"html":{"href":"https://github.com/yershovkiril/store/pull/1#discussion_r73215138"},"pull_request":{"href":"https://api.github.com/repos/yershovkiril/store/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/yershovkiril/store/pulls/1","id":78906983,"html_url":"https://github.com/yershovkiril/store/pull/1","diff_url":"https://github.com/yershovkiril/store/pull/1.diff","patch_url":"https://github.com/yershovkiril/store/pull/1.patch","issue_url":"https://api.github.com/repos/yershovkiril/store/issues/1","number":1,"state":"open","locked":false,"title":"review","user":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-26T19:05:53Z","updated_at":"2016-08-02T18:52:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38e0ee50e9c70579ce12c1a5078e7d5dec5be157","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/yershovkiril/store/pulls/1/commits","review_comments_url":"https://api.github.com/repos/yershovkiril/store/pulls/1/comments","review_comment_url":"https://api.github.com/repos/yershovkiril/store/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yershovkiril/store/issues/1/comments","statuses_url":"https://api.github.com/repos/yershovkiril/store/statuses/afde7ff54f031d9dcc5df767a201fe131d258766","head":{"label":"yershovkiril:review","ref":"review","sha":"afde7ff54f031d9dcc5df767a201fe131d258766","user":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"repo":{"id":64246742,"name":"store","full_name":"yershovkiril/store","owner":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yershovkiril/store","description":"https://safe-sierra-95531.herokuapp.com/","fork":false,"url":"https://api.github.com/repos/yershovkiril/store","forks_url":"https://api.github.com/repos/yershovkiril/store/forks","keys_url":"https://api.github.com/repos/yershovkiril/store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yershovkiril/store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yershovkiril/store/teams","hooks_url":"https://api.github.com/repos/yershovkiril/store/hooks","issue_events_url":"https://api.github.com/repos/yershovkiril/store/issues/events{/number}","events_url":"https://api.github.com/repos/yershovkiril/store/events","assignees_url":"https://api.github.com/repos/yershovkiril/store/assignees{/user}","branches_url":"https://api.github.com/repos/yershovkiril/store/branches{/branch}","tags_url":"https://api.github.com/repos/yershovkiril/store/tags","blobs_url":"https://api.github.com/repos/yershovkiril/store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yershovkiril/store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yershovkiril/store/git/refs{/sha}","trees_url":"https://api.github.com/repos/yershovkiril/store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yershovkiril/store/statuses/{sha}","languages_url":"https://api.github.com/repos/yershovkiril/store/languages","stargazers_url":"https://api.github.com/repos/yershovkiril/store/stargazers","contributors_url":"https://api.github.com/repos/yershovkiril/store/contributors","subscribers_url":"https://api.github.com/repos/yershovkiril/store/subscribers","subscription_url":"https://api.github.com/repos/yershovkiril/store/subscription","commits_url":"https://api.github.com/repos/yershovkiril/store/commits{/sha}","git_commits_url":"https://api.github.com/repos/yershovkiril/store/git/commits{/sha}","comments_url":"https://api.github.com/repos/yershovkiril/store/comments{/number}","issue_comment_url":"https://api.github.com/repos/yershovkiril/store/issues/comments{/number}","contents_url":"https://api.github.com/repos/yershovkiril/store/contents/{+path}","compare_url":"https://api.github.com/repos/yershovkiril/store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yershovkiril/store/merges","archive_url":"https://api.github.com/repos/yershovkiril/store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yershovkiril/store/downloads","issues_url":"https://api.github.com/repos/yershovkiril/store/issues{/number}","pulls_url":"https://api.github.com/repos/yershovkiril/store/pulls{/number}","milestones_url":"https://api.github.com/repos/yershovkiril/store/milestones{/number}","notifications_url":"https://api.github.com/repos/yershovkiril/store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yershovkiril/store/labels{/name}","releases_url":"https://api.github.com/repos/yershovkiril/store/releases{/id}","deployments_url":"https://api.github.com/repos/yershovkiril/store/deployments","created_at":"2016-07-26T18:59:59Z","updated_at":"2016-07-27T07:49:33Z","pushed_at":"2016-08-02T18:42:02Z","git_url":"git://github.com/yershovkiril/store.git","ssh_url":"git@github.com:yershovkiril/store.git","clone_url":"https://github.com/yershovkiril/store.git","svn_url":"https://github.com/yershovkiril/store","homepage":"","size":117,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":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":"yershovkiril:master","ref":"master","sha":"74dac64cab8d58df21b67b81b5ca74e7d05ef3e0","user":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"repo":{"id":64246742,"name":"store","full_name":"yershovkiril/store","owner":{"login":"yershovkiril","id":13396635,"avatar_url":"https://avatars.githubusercontent.com/u/13396635?v=3","gravatar_id":"","url":"https://api.github.com/users/yershovkiril","html_url":"https://github.com/yershovkiril","followers_url":"https://api.github.com/users/yershovkiril/followers","following_url":"https://api.github.com/users/yershovkiril/following{/other_user}","gists_url":"https://api.github.com/users/yershovkiril/gists{/gist_id}","starred_url":"https://api.github.com/users/yershovkiril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yershovkiril/subscriptions","organizations_url":"https://api.github.com/users/yershovkiril/orgs","repos_url":"https://api.github.com/users/yershovkiril/repos","events_url":"https://api.github.com/users/yershovkiril/events{/privacy}","received_events_url":"https://api.github.com/users/yershovkiril/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yershovkiril/store","description":"https://safe-sierra-95531.herokuapp.com/","fork":false,"url":"https://api.github.com/repos/yershovkiril/store","forks_url":"https://api.github.com/repos/yershovkiril/store/forks","keys_url":"https://api.github.com/repos/yershovkiril/store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yershovkiril/store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yershovkiril/store/teams","hooks_url":"https://api.github.com/repos/yershovkiril/store/hooks","issue_events_url":"https://api.github.com/repos/yershovkiril/store/issues/events{/number}","events_url":"https://api.github.com/repos/yershovkiril/store/events","assignees_url":"https://api.github.com/repos/yershovkiril/store/assignees{/user}","branches_url":"https://api.github.com/repos/yershovkiril/store/branches{/branch}","tags_url":"https://api.github.com/repos/yershovkiril/store/tags","blobs_url":"https://api.github.com/repos/yershovkiril/store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yershovkiril/store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yershovkiril/store/git/refs{/sha}","trees_url":"https://api.github.com/repos/yershovkiril/store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yershovkiril/store/statuses/{sha}","languages_url":"https://api.github.com/repos/yershovkiril/store/languages","stargazers_url":"https://api.github.com/repos/yershovkiril/store/stargazers","contributors_url":"https://api.github.com/repos/yershovkiril/store/contributors","subscribers_url":"https://api.github.com/repos/yershovkiril/store/subscribers","subscription_url":"https://api.github.com/repos/yershovkiril/store/subscription","commits_url":"https://api.github.com/repos/yershovkiril/store/commits{/sha}","git_commits_url":"https://api.github.com/repos/yershovkiril/store/git/commits{/sha}","comments_url":"https://api.github.com/repos/yershovkiril/store/comments{/number}","issue_comment_url":"https://api.github.com/repos/yershovkiril/store/issues/comments{/number}","contents_url":"https://api.github.com/repos/yershovkiril/store/contents/{+path}","compare_url":"https://api.github.com/repos/yershovkiril/store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yershovkiril/store/merges","archive_url":"https://api.github.com/repos/yershovkiril/store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yershovkiril/store/downloads","issues_url":"https://api.github.com/repos/yershovkiril/store/issues{/number}","pulls_url":"https://api.github.com/repos/yershovkiril/store/pulls{/number}","milestones_url":"https://api.github.com/repos/yershovkiril/store/milestones{/number}","notifications_url":"https://api.github.com/repos/yershovkiril/store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yershovkiril/store/labels{/name}","releases_url":"https://api.github.com/repos/yershovkiril/store/releases{/id}","deployments_url":"https://api.github.com/repos/yershovkiril/store/deployments","created_at":"2016-07-26T18:59:59Z","updated_at":"2016-07-27T07:49:33Z","pushed_at":"2016-08-02T18:42:02Z","git_url":"git://github.com/yershovkiril/store.git","ssh_url":"git@github.com:yershovkiril/store.git","clone_url":"https://github.com/yershovkiril/store.git","svn_url":"https://github.com/yershovkiril/store","homepage":"","size":117,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":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/yershovkiril/store/pulls/1"},"html":{"href":"https://github.com/yershovkiril/store/pull/1"},"issue":{"href":"https://api.github.com/repos/yershovkiril/store/issues/1"},"comments":{"href":"https://api.github.com/repos/yershovkiril/store/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/yershovkiril/store/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/yershovkiril/store/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yershovkiril/store/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/yershovkiril/store/statuses/afde7ff54f031d9dcc5df767a201fe131d258766"}}}}
{"actor":{"display_login":"yershovkiril"}}