{"action":"created","comment":{"url":"https://api.github.com/repos/vrish88/gradebook/pulls/comments/33381241","id":33381241,"diff_hunk":"@@ -0,0 +1,25 @@\n+class CreateGradeYear < ROM::Commands::Create[:sql]\n+  relation :grade_years\n+  register_as :create\n+  result :one\n+\n+  def execute(attributes)\n+    gpa = attributes.delete(:gpa).to_f\n+    if gpa > 3\n+      letter = 'A'\n+    elsif gpa > 1\n+      letter = 'D'\n+    end\n+\n+    grade = Grade.find_by_letter(letter)\n+    grade_year = GradeYear.create!(\n+      student_id: attributes[:student_id],\n+      gpa: gpa,\n+      grade_id: grade.id,\n+      year: attributes[:year]\n+    )","path":"app/commands/create_grade_year.rb","position":20,"original_position":20,"commit_id":"c9fa054c1a5540ba523acf8c4cfa4495a5d5e426","original_commit_id":"c9fa054c1a5540ba523acf8c4cfa4495a5d5e426","user":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"body":"I'd really like to start using ROM at work but in order to do that I'll have to get buy in from my coworkers and to do that the transition is going to have to be incremental.\r\n\r\nROM has a great paradigm but one that is unfamiliar to most rails devs. This first pass is a way to start separating code. Then in the next step I'd like to start replacing the AR stuff with ROM relations and POROs.\r\n\r\nSo for this command I imagine that figuring out of gpa to grade would be one component and then the creation of the actual grade year would be done by a relation. Still have to figure out how to do that though :)","created_at":"2015-06-26T18:18:15Z","updated_at":"2015-06-26T18:18:15Z","html_url":"https://github.com/vrish88/gradebook/pull/1#discussion_r33381241","pull_request_url":"https://api.github.com/repos/vrish88/gradebook/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/vrish88/gradebook/pulls/comments/33381241"},"html":{"href":"https://github.com/vrish88/gradebook/pull/1#discussion_r33381241"},"pull_request":{"href":"https://api.github.com/repos/vrish88/gradebook/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/vrish88/gradebook/pulls/1","id":38617663,"html_url":"https://github.com/vrish88/gradebook/pull/1","diff_url":"https://github.com/vrish88/gradebook/pull/1.diff","patch_url":"https://github.com/vrish88/gradebook/pull/1.patch","issue_url":"https://api.github.com/repos/vrish88/gradebook/issues/1","number":1,"state":"open","locked":false,"title":"ROM way","user":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"body":"Here's an ill fated attempt at solving this problem with ROM.\r\n\r\nI tried to take small steps moving from ActiveRecord to ROM relations, mappers, and commands. The first step was to just move the creation of `GradeYear` into a command and then move use a mapper on the relation.\r\n\r\nSecond was to use a mapper to map the grades by their years. This didn't go as well and it took some digging to get a `ROM::Mapper` to return a hash.","created_at":"2015-06-26T05:03:58Z","updated_at":"2015-06-26T18:18:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffe496d87f9817ed5e8c1ffec7b5e61dfa828584","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vrish88/gradebook/pulls/1/commits","review_comments_url":"https://api.github.com/repos/vrish88/gradebook/pulls/1/comments","review_comment_url":"https://api.github.com/repos/vrish88/gradebook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vrish88/gradebook/issues/1/comments","statuses_url":"https://api.github.com/repos/vrish88/gradebook/statuses/c9fa054c1a5540ba523acf8c4cfa4495a5d5e426","head":{"label":"vrish88:rom-way","ref":"rom-way","sha":"c9fa054c1a5540ba523acf8c4cfa4495a5d5e426","user":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"repo":{"id":37778637,"name":"gradebook","full_name":"vrish88/gradebook","owner":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vrish88/gradebook","description":"Sample problem to see how ROM would work in a rails app","fork":false,"url":"https://api.github.com/repos/vrish88/gradebook","forks_url":"https://api.github.com/repos/vrish88/gradebook/forks","keys_url":"https://api.github.com/repos/vrish88/gradebook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vrish88/gradebook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vrish88/gradebook/teams","hooks_url":"https://api.github.com/repos/vrish88/gradebook/hooks","issue_events_url":"https://api.github.com/repos/vrish88/gradebook/issues/events{/number}","events_url":"https://api.github.com/repos/vrish88/gradebook/events","assignees_url":"https://api.github.com/repos/vrish88/gradebook/assignees{/user}","branches_url":"https://api.github.com/repos/vrish88/gradebook/branches{/branch}","tags_url":"https://api.github.com/repos/vrish88/gradebook/tags","blobs_url":"https://api.github.com/repos/vrish88/gradebook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vrish88/gradebook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vrish88/gradebook/git/refs{/sha}","trees_url":"https://api.github.com/repos/vrish88/gradebook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vrish88/gradebook/statuses/{sha}","languages_url":"https://api.github.com/repos/vrish88/gradebook/languages","stargazers_url":"https://api.github.com/repos/vrish88/gradebook/stargazers","contributors_url":"https://api.github.com/repos/vrish88/gradebook/contributors","subscribers_url":"https://api.github.com/repos/vrish88/gradebook/subscribers","subscription_url":"https://api.github.com/repos/vrish88/gradebook/subscription","commits_url":"https://api.github.com/repos/vrish88/gradebook/commits{/sha}","git_commits_url":"https://api.github.com/repos/vrish88/gradebook/git/commits{/sha}","comments_url":"https://api.github.com/repos/vrish88/gradebook/comments{/number}","issue_comment_url":"https://api.github.com/repos/vrish88/gradebook/issues/comments{/number}","contents_url":"https://api.github.com/repos/vrish88/gradebook/contents/{+path}","compare_url":"https://api.github.com/repos/vrish88/gradebook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vrish88/gradebook/merges","archive_url":"https://api.github.com/repos/vrish88/gradebook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vrish88/gradebook/downloads","issues_url":"https://api.github.com/repos/vrish88/gradebook/issues{/number}","pulls_url":"https://api.github.com/repos/vrish88/gradebook/pulls{/number}","milestones_url":"https://api.github.com/repos/vrish88/gradebook/milestones{/number}","notifications_url":"https://api.github.com/repos/vrish88/gradebook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vrish88/gradebook/labels{/name}","releases_url":"https://api.github.com/repos/vrish88/gradebook/releases{/id}","created_at":"2015-06-20T17:23:29Z","updated_at":"2015-06-20T17:23:53Z","pushed_at":"2015-06-26T05:03:58Z","git_url":"git://github.com/vrish88/gradebook.git","ssh_url":"git@github.com:vrish88/gradebook.git","clone_url":"https://github.com/vrish88/gradebook.git","svn_url":"https://github.com/vrish88/gradebook","homepage":null,"size":0,"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":"vrish88:master","ref":"master","sha":"367c0921c006133113a85cdfe4c037d82de119fd","user":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"repo":{"id":37778637,"name":"gradebook","full_name":"vrish88/gradebook","owner":{"login":"vrish88","id":36475,"avatar_url":"https://avatars.githubusercontent.com/u/36475?v=3","gravatar_id":"","url":"https://api.github.com/users/vrish88","html_url":"https://github.com/vrish88","followers_url":"https://api.github.com/users/vrish88/followers","following_url":"https://api.github.com/users/vrish88/following{/other_user}","gists_url":"https://api.github.com/users/vrish88/gists{/gist_id}","starred_url":"https://api.github.com/users/vrish88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrish88/subscriptions","organizations_url":"https://api.github.com/users/vrish88/orgs","repos_url":"https://api.github.com/users/vrish88/repos","events_url":"https://api.github.com/users/vrish88/events{/privacy}","received_events_url":"https://api.github.com/users/vrish88/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vrish88/gradebook","description":"Sample problem to see how ROM would work in a rails app","fork":false,"url":"https://api.github.com/repos/vrish88/gradebook","forks_url":"https://api.github.com/repos/vrish88/gradebook/forks","keys_url":"https://api.github.com/repos/vrish88/gradebook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vrish88/gradebook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vrish88/gradebook/teams","hooks_url":"https://api.github.com/repos/vrish88/gradebook/hooks","issue_events_url":"https://api.github.com/repos/vrish88/gradebook/issues/events{/number}","events_url":"https://api.github.com/repos/vrish88/gradebook/events","assignees_url":"https://api.github.com/repos/vrish88/gradebook/assignees{/user}","branches_url":"https://api.github.com/repos/vrish88/gradebook/branches{/branch}","tags_url":"https://api.github.com/repos/vrish88/gradebook/tags","blobs_url":"https://api.github.com/repos/vrish88/gradebook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vrish88/gradebook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vrish88/gradebook/git/refs{/sha}","trees_url":"https://api.github.com/repos/vrish88/gradebook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vrish88/gradebook/statuses/{sha}","languages_url":"https://api.github.com/repos/vrish88/gradebook/languages","stargazers_url":"https://api.github.com/repos/vrish88/gradebook/stargazers","contributors_url":"https://api.github.com/repos/vrish88/gradebook/contributors","subscribers_url":"https://api.github.com/repos/vrish88/gradebook/subscribers","subscription_url":"https://api.github.com/repos/vrish88/gradebook/subscription","commits_url":"https://api.github.com/repos/vrish88/gradebook/commits{/sha}","git_commits_url":"https://api.github.com/repos/vrish88/gradebook/git/commits{/sha}","comments_url":"https://api.github.com/repos/vrish88/gradebook/comments{/number}","issue_comment_url":"https://api.github.com/repos/vrish88/gradebook/issues/comments{/number}","contents_url":"https://api.github.com/repos/vrish88/gradebook/contents/{+path}","compare_url":"https://api.github.com/repos/vrish88/gradebook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vrish88/gradebook/merges","archive_url":"https://api.github.com/repos/vrish88/gradebook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vrish88/gradebook/downloads","issues_url":"https://api.github.com/repos/vrish88/gradebook/issues{/number}","pulls_url":"https://api.github.com/repos/vrish88/gradebook/pulls{/number}","milestones_url":"https://api.github.com/repos/vrish88/gradebook/milestones{/number}","notifications_url":"https://api.github.com/repos/vrish88/gradebook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vrish88/gradebook/labels{/name}","releases_url":"https://api.github.com/repos/vrish88/gradebook/releases{/id}","created_at":"2015-06-20T17:23:29Z","updated_at":"2015-06-20T17:23:53Z","pushed_at":"2015-06-26T05:03:58Z","git_url":"git://github.com/vrish88/gradebook.git","ssh_url":"git@github.com:vrish88/gradebook.git","clone_url":"https://github.com/vrish88/gradebook.git","svn_url":"https://github.com/vrish88/gradebook","homepage":null,"size":0,"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/vrish88/gradebook/pulls/1"},"html":{"href":"https://github.com/vrish88/gradebook/pull/1"},"issue":{"href":"https://api.github.com/repos/vrish88/gradebook/issues/1"},"comments":{"href":"https://api.github.com/repos/vrish88/gradebook/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/vrish88/gradebook/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/vrish88/gradebook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vrish88/gradebook/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/vrish88/gradebook/statuses/c9fa054c1a5540ba523acf8c4cfa4495a5d5e426"}}}}