{"action":"created","comment":{"url":"https://api.github.com/repos/instructure/ims-lti/pulls/comments/38793160","id":38793160,"diff_hunk":"@@ -73,20 +85,8 @@ def supers_params(instance_variable)\n     add_required_params :lti_message_type, :lti_version\n \n     def self.generate(params)\n-      case params['lti_message_type']\n-        when BasicLTILaunchRequest::MESSAGE_TYPE\n-          BasicLTILaunchRequest.new(params)\n-        when RegistrationRequest::MESSAGE_TYPE\n-          RegistrationRequest.new(params)\n-        when ContentItemSelectionRequest::MESSAGE_TYPE\n-          ContentItemSelectionRequest.new(params)\n-        when ContentItemSelection::MESSAGE_TYPE\n-          ContentItemSelection.new(params)\n-        when ToolProxyReregistrationRequest::MESSAGE_TYPE\n-          ToolProxyReregistrationRequest.new(params)\n-        else\n-          self.new(params)\n-      end\n+      klass = self.descendants.select{|d| d::MESSAGE_TYPE == params['lti_message_type']}.first\n+      klass ? klass.new(params) : self.new(params)","path":"lib/ims/lti/models/messages/message.rb","position":45,"original_position":45,"commit_id":"65c39b11c5ea172da41ec3b9f8b61f67eee12e5f","original_commit_id":"65c39b11c5ea172da41ec3b9f8b61f67eee12e5f","user":{"login":"rivernate","id":531217,"avatar_url":"https://avatars.githubusercontent.com/u/531217?v=3","gravatar_id":"","url":"https://api.github.com/users/rivernate","html_url":"https://github.com/rivernate","followers_url":"https://api.github.com/users/rivernate/followers","following_url":"https://api.github.com/users/rivernate/following{/other_user}","gists_url":"https://api.github.com/users/rivernate/gists{/gist_id}","starred_url":"https://api.github.com/users/rivernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rivernate/subscriptions","organizations_url":"https://api.github.com/users/rivernate/orgs","repos_url":"https://api.github.com/users/rivernate/repos","events_url":"https://api.github.com/users/rivernate/events{/privacy}","received_events_url":"https://api.github.com/users/rivernate/received_events","type":"User","site_admin":false},"body":"I'm wondering if I should change the self.new on line 89 to Message.new. The side effect of the way it is now is that the default type created is whatever class you call it from, so if you call it from RequestMessage it will only return one of it's subtypes or itself. thoughts?","created_at":"2015-09-04T20:55:11Z","updated_at":"2015-09-04T20:55:11Z","html_url":"https://github.com/instructure/ims-lti/pull/58#discussion_r38793160","pull_request_url":"https://api.github.com/repos/instructure/ims-lti/pulls/58","_links":{"self":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/comments/38793160"},"html":{"href":"https://github.com/instructure/ims-lti/pull/58#discussion_r38793160"},"pull_request":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/58"}}},"pull_request":{"url":"https://api.github.com/repos/instructure/ims-lti/pulls/58","id":44260250,"html_url":"https://github.com/instructure/ims-lti/pull/58","diff_url":"https://github.com/instructure/ims-lti/pull/58.diff","patch_url":"https://github.com/instructure/ims-lti/pull/58.patch","issue_url":"https://api.github.com/repos/instructure/ims-lti/issues/58","number":58,"state":"open","locked":false,"title":"make the generate message method dynamic","user":{"login":"rivernate","id":531217,"avatar_url":"https://avatars.githubusercontent.com/u/531217?v=3","gravatar_id":"","url":"https://api.github.com/users/rivernate","html_url":"https://github.com/rivernate","followers_url":"https://api.github.com/users/rivernate/followers","following_url":"https://api.github.com/users/rivernate/following{/other_user}","gists_url":"https://api.github.com/users/rivernate/gists{/gist_id}","starred_url":"https://api.github.com/users/rivernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rivernate/subscriptions","organizations_url":"https://api.github.com/users/rivernate/orgs","repos_url":"https://api.github.com/users/rivernate/repos","events_url":"https://api.github.com/users/rivernate/events{/privacy}","received_events_url":"https://api.github.com/users/rivernate/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-04T20:51:49Z","updated_at":"2015-09-04T20:55:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e1785f179be8f08235db103e85ae3ba6c588361","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/instructure/ims-lti/pulls/58/commits","review_comments_url":"https://api.github.com/repos/instructure/ims-lti/pulls/58/comments","review_comment_url":"https://api.github.com/repos/instructure/ims-lti/pulls/comments{/number}","comments_url":"https://api.github.com/repos/instructure/ims-lti/issues/58/comments","statuses_url":"https://api.github.com/repos/instructure/ims-lti/statuses/65c39b11c5ea172da41ec3b9f8b61f67eee12e5f","head":{"label":"rivernate:2.0.x","ref":"2.0.x","sha":"65c39b11c5ea172da41ec3b9f8b61f67eee12e5f","user":{"login":"rivernate","id":531217,"avatar_url":"https://avatars.githubusercontent.com/u/531217?v=3","gravatar_id":"","url":"https://api.github.com/users/rivernate","html_url":"https://github.com/rivernate","followers_url":"https://api.github.com/users/rivernate/followers","following_url":"https://api.github.com/users/rivernate/following{/other_user}","gists_url":"https://api.github.com/users/rivernate/gists{/gist_id}","starred_url":"https://api.github.com/users/rivernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rivernate/subscriptions","organizations_url":"https://api.github.com/users/rivernate/orgs","repos_url":"https://api.github.com/users/rivernate/repos","events_url":"https://api.github.com/users/rivernate/events{/privacy}","received_events_url":"https://api.github.com/users/rivernate/received_events","type":"User","site_admin":false},"repo":{"id":24658304,"name":"ims-lti","full_name":"rivernate/ims-lti","owner":{"login":"rivernate","id":531217,"avatar_url":"https://avatars.githubusercontent.com/u/531217?v=3","gravatar_id":"","url":"https://api.github.com/users/rivernate","html_url":"https://github.com/rivernate","followers_url":"https://api.github.com/users/rivernate/followers","following_url":"https://api.github.com/users/rivernate/following{/other_user}","gists_url":"https://api.github.com/users/rivernate/gists{/gist_id}","starred_url":"https://api.github.com/users/rivernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rivernate/subscriptions","organizations_url":"https://api.github.com/users/rivernate/orgs","repos_url":"https://api.github.com/users/rivernate/repos","events_url":"https://api.github.com/users/rivernate/events{/privacy}","received_events_url":"https://api.github.com/users/rivernate/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rivernate/ims-lti","description":"A Ruby library to help implement IMS LTI tool consumers and providers","fork":true,"url":"https://api.github.com/repos/rivernate/ims-lti","forks_url":"https://api.github.com/repos/rivernate/ims-lti/forks","keys_url":"https://api.github.com/repos/rivernate/ims-lti/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rivernate/ims-lti/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rivernate/ims-lti/teams","hooks_url":"https://api.github.com/repos/rivernate/ims-lti/hooks","issue_events_url":"https://api.github.com/repos/rivernate/ims-lti/issues/events{/number}","events_url":"https://api.github.com/repos/rivernate/ims-lti/events","assignees_url":"https://api.github.com/repos/rivernate/ims-lti/assignees{/user}","branches_url":"https://api.github.com/repos/rivernate/ims-lti/branches{/branch}","tags_url":"https://api.github.com/repos/rivernate/ims-lti/tags","blobs_url":"https://api.github.com/repos/rivernate/ims-lti/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rivernate/ims-lti/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rivernate/ims-lti/git/refs{/sha}","trees_url":"https://api.github.com/repos/rivernate/ims-lti/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rivernate/ims-lti/statuses/{sha}","languages_url":"https://api.github.com/repos/rivernate/ims-lti/languages","stargazers_url":"https://api.github.com/repos/rivernate/ims-lti/stargazers","contributors_url":"https://api.github.com/repos/rivernate/ims-lti/contributors","subscribers_url":"https://api.github.com/repos/rivernate/ims-lti/subscribers","subscription_url":"https://api.github.com/repos/rivernate/ims-lti/subscription","commits_url":"https://api.github.com/repos/rivernate/ims-lti/commits{/sha}","git_commits_url":"https://api.github.com/repos/rivernate/ims-lti/git/commits{/sha}","comments_url":"https://api.github.com/repos/rivernate/ims-lti/comments{/number}","issue_comment_url":"https://api.github.com/repos/rivernate/ims-lti/issues/comments{/number}","contents_url":"https://api.github.com/repos/rivernate/ims-lti/contents/{+path}","compare_url":"https://api.github.com/repos/rivernate/ims-lti/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rivernate/ims-lti/merges","archive_url":"https://api.github.com/repos/rivernate/ims-lti/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rivernate/ims-lti/downloads","issues_url":"https://api.github.com/repos/rivernate/ims-lti/issues{/number}","pulls_url":"https://api.github.com/repos/rivernate/ims-lti/pulls{/number}","milestones_url":"https://api.github.com/repos/rivernate/ims-lti/milestones{/number}","notifications_url":"https://api.github.com/repos/rivernate/ims-lti/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rivernate/ims-lti/labels{/name}","releases_url":"https://api.github.com/repos/rivernate/ims-lti/releases{/id}","created_at":"2014-09-30T22:40:13Z","updated_at":"2015-08-31T19:54:29Z","pushed_at":"2015-09-04T20:51:22Z","git_url":"git://github.com/rivernate/ims-lti.git","ssh_url":"git@github.com:rivernate/ims-lti.git","clone_url":"https://github.com/rivernate/ims-lti.git","svn_url":"https://github.com/rivernate/ims-lti","homepage":"","size":380,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"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":"instructure:2.0.x","ref":"2.0.x","sha":"02c523bbba98bb6d450104b7d25562f472623f7b","user":{"login":"instructure","id":515326,"avatar_url":"https://avatars.githubusercontent.com/u/515326?v=3","gravatar_id":"","url":"https://api.github.com/users/instructure","html_url":"https://github.com/instructure","followers_url":"https://api.github.com/users/instructure/followers","following_url":"https://api.github.com/users/instructure/following{/other_user}","gists_url":"https://api.github.com/users/instructure/gists{/gist_id}","starred_url":"https://api.github.com/users/instructure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/instructure/subscriptions","organizations_url":"https://api.github.com/users/instructure/orgs","repos_url":"https://api.github.com/users/instructure/repos","events_url":"https://api.github.com/users/instructure/events{/privacy}","received_events_url":"https://api.github.com/users/instructure/received_events","type":"Organization","site_admin":false},"repo":{"id":3641377,"name":"ims-lti","full_name":"instructure/ims-lti","owner":{"login":"instructure","id":515326,"avatar_url":"https://avatars.githubusercontent.com/u/515326?v=3","gravatar_id":"","url":"https://api.github.com/users/instructure","html_url":"https://github.com/instructure","followers_url":"https://api.github.com/users/instructure/followers","following_url":"https://api.github.com/users/instructure/following{/other_user}","gists_url":"https://api.github.com/users/instructure/gists{/gist_id}","starred_url":"https://api.github.com/users/instructure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/instructure/subscriptions","organizations_url":"https://api.github.com/users/instructure/orgs","repos_url":"https://api.github.com/users/instructure/repos","events_url":"https://api.github.com/users/instructure/events{/privacy}","received_events_url":"https://api.github.com/users/instructure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/instructure/ims-lti","description":"A Ruby library to help implement IMS LTI tool consumers and providers","fork":false,"url":"https://api.github.com/repos/instructure/ims-lti","forks_url":"https://api.github.com/repos/instructure/ims-lti/forks","keys_url":"https://api.github.com/repos/instructure/ims-lti/keys{/key_id}","collaborators_url":"https://api.github.com/repos/instructure/ims-lti/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/instructure/ims-lti/teams","hooks_url":"https://api.github.com/repos/instructure/ims-lti/hooks","issue_events_url":"https://api.github.com/repos/instructure/ims-lti/issues/events{/number}","events_url":"https://api.github.com/repos/instructure/ims-lti/events","assignees_url":"https://api.github.com/repos/instructure/ims-lti/assignees{/user}","branches_url":"https://api.github.com/repos/instructure/ims-lti/branches{/branch}","tags_url":"https://api.github.com/repos/instructure/ims-lti/tags","blobs_url":"https://api.github.com/repos/instructure/ims-lti/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/instructure/ims-lti/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/instructure/ims-lti/git/refs{/sha}","trees_url":"https://api.github.com/repos/instructure/ims-lti/git/trees{/sha}","statuses_url":"https://api.github.com/repos/instructure/ims-lti/statuses/{sha}","languages_url":"https://api.github.com/repos/instructure/ims-lti/languages","stargazers_url":"https://api.github.com/repos/instructure/ims-lti/stargazers","contributors_url":"https://api.github.com/repos/instructure/ims-lti/contributors","subscribers_url":"https://api.github.com/repos/instructure/ims-lti/subscribers","subscription_url":"https://api.github.com/repos/instructure/ims-lti/subscription","commits_url":"https://api.github.com/repos/instructure/ims-lti/commits{/sha}","git_commits_url":"https://api.github.com/repos/instructure/ims-lti/git/commits{/sha}","comments_url":"https://api.github.com/repos/instructure/ims-lti/comments{/number}","issue_comment_url":"https://api.github.com/repos/instructure/ims-lti/issues/comments{/number}","contents_url":"https://api.github.com/repos/instructure/ims-lti/contents/{+path}","compare_url":"https://api.github.com/repos/instructure/ims-lti/compare/{base}...{head}","merges_url":"https://api.github.com/repos/instructure/ims-lti/merges","archive_url":"https://api.github.com/repos/instructure/ims-lti/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/instructure/ims-lti/downloads","issues_url":"https://api.github.com/repos/instructure/ims-lti/issues{/number}","pulls_url":"https://api.github.com/repos/instructure/ims-lti/pulls{/number}","milestones_url":"https://api.github.com/repos/instructure/ims-lti/milestones{/number}","notifications_url":"https://api.github.com/repos/instructure/ims-lti/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/instructure/ims-lti/labels{/name}","releases_url":"https://api.github.com/repos/instructure/ims-lti/releases{/id}","created_at":"2012-03-06T18:58:45Z","updated_at":"2015-08-23T16:57:48Z","pushed_at":"2015-09-04T20:51:49Z","git_url":"git://github.com/instructure/ims-lti.git","ssh_url":"git@github.com:instructure/ims-lti.git","clone_url":"https://github.com/instructure/ims-lti.git","svn_url":"https://github.com/instructure/ims-lti","homepage":"","size":723,"stargazers_count":73,"watchers_count":73,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":8,"forks":37,"open_issues":8,"watchers":73,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/58"},"html":{"href":"https://github.com/instructure/ims-lti/pull/58"},"issue":{"href":"https://api.github.com/repos/instructure/ims-lti/issues/58"},"comments":{"href":"https://api.github.com/repos/instructure/ims-lti/issues/58/comments"},"review_comments":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/58/comments"},"review_comment":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/instructure/ims-lti/pulls/58/commits"},"statuses":{"href":"https://api.github.com/repos/instructure/ims-lti/statuses/65c39b11c5ea172da41ec3b9f8b61f67eee12e5f"}}}}