GitHub PullRequestReviewCommentEvent at 2014-10-22 04:04:02
Repository: frolfr
Actor: pdougall1
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/comments/19193656","id":19193656,"diff_hunk":"@@ -0,0 +1,20 @@\n+App.AuthenticatedRoute = Ember.Route.extend({\n+  beforeModel: function(transition) {\n+    if (Ember.isEmpty(this.controllerFor('sessions').get('token'))) {\n+      return this.redirectToLogin(transition);","path":"app/assets/javascripts/routes/authenticated_route.js","position":4,"original_position":4,"commit_id":"c7748f98191974d17099dcd573814fe81f201629","original_commit_id":"e51d1af0fcb304a2aca0a82d674998cd4f1e58c0","user":{"login":"pdougall1","id":1535363,"avatar_url":"https://avatars.githubusercontent.com/u/1535363?v=2","gravatar_id":"","url":"https://api.github.com/users/pdougall1","html_url":"https://github.com/pdougall1","followers_url":"https://api.github.com/users/pdougall1/followers","following_url":"https://api.github.com/users/pdougall1/following{/other_user}","gists_url":"https://api.github.com/users/pdougall1/gists{/gist_id}","starred_url":"https://api.github.com/users/pdougall1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pdougall1/subscriptions","organizations_url":"https://api.github.com/users/pdougall1/orgs","repos_url":"https://api.github.com/users/pdougall1/repos","events_url":"https://api.github.com/users/pdougall1/events{/privacy}","received_events_url":"https://api.github.com/users/pdougall1/received_events","type":"User","site_admin":false},"body":"Well this comment sent me down a bit of a rabbit hole trying to find good clarification.  I think [\"this\" post by Yahuda Katz](http://yehudakatz.com/2011/08/11/understanding-javascript-function-invocation-and-this/) actually does a pretty thorough job of getting to the root of it.  \r\n\r\nI know `extend` is doing more complicated stuff to add methods through inheritance, but what you pointed out is a little simpler.  It's basically just that `beforeModel ` is a key in an object literal and that function is the value, so the scope of \"this\" inside that function is still the object literal.  So it at least has access to other keys in the object like `redirectToLogin`.  Same logic that makes this work.\r\n\r\n``` javascript\r\nvar regularObject = {\r\n  someFunc: function () {\r\n    console.log(this);\r\n  }\r\n}\r\nregularObject.someFunc(); // => { someFunc: [Function] }\r\n```\r\n\r\nI went down the rabbit hole of trying to figure out how ember extends objects and then how js creates them.  Gets a little disorienting down there. I think it may look like this: the object that gets passed in gets integrated into the prototype of the consuming object, and then eventually `App.AuthenticatedRoute ` gets `create`d and suddenly :boom: the prototypes are instance methods.","created_at":"2014-10-22T04:04:02Z","updated_at":"2014-10-22T04:04:02Z","html_url":"https://github.com/gschorkopf/frolfr/pull/23#discussion_r19193656","pull_request_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/comments/19193656"},"html":{"href":"https://github.com/gschorkopf/frolfr/pull/23#discussion_r19193656"},"pull_request":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23","id":22511376,"html_url":"https://github.com/gschorkopf/frolfr/pull/23","diff_url":"https://github.com/gschorkopf/frolfr/pull/23.diff","patch_url":"https://github.com/gschorkopf/frolfr/pull/23.patch","issue_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/23","number":23,"state":"open","locked":false,"title":"Killpack/auth ","user":{"login":"killpack","id":3970187,"avatar_url":"https://avatars.githubusercontent.com/u/3970187?v=2","gravatar_id":"","url":"https://api.github.com/users/killpack","html_url":"https://github.com/killpack","followers_url":"https://api.github.com/users/killpack/followers","following_url":"https://api.github.com/users/killpack/following{/other_user}","gists_url":"https://api.github.com/users/killpack/gists{/gist_id}","starred_url":"https://api.github.com/users/killpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/killpack/subscriptions","organizations_url":"https://api.github.com/users/killpack/orgs","repos_url":"https://api.github.com/users/killpack/repos","events_url":"https://api.github.com/users/killpack/events{/privacy}","received_events_url":"https://api.github.com/users/killpack/received_events","type":"User","site_admin":false},"body":"\r\nIt's gonna work like this:\r\n- You type in your username and password, which hits the `authorizations` endpoint. On successful authentication, it returns your auth token.\r\n- Ember stores this auth token somewhere and uses it to make requests from thereon out.","created_at":"2014-10-09T17:56:28Z","updated_at":"2014-10-22T04:04:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8418e6f8d1c02e5ee62952c0c202b861139dc430","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23/commits","review_comments_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23/comments","review_comment_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls/comments/{number}","comments_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/23/comments","statuses_url":"https://api.github.com/repos/gschorkopf/frolfr/statuses/c7748f98191974d17099dcd573814fe81f201629","head":{"label":"gschorkopf:killpack/auth","ref":"killpack/auth","sha":"c7748f98191974d17099dcd573814fe81f201629","user":{"login":"gschorkopf","id":2623668,"avatar_url":"https://avatars.githubusercontent.com/u/2623668?v=2","gravatar_id":"","url":"https://api.github.com/users/gschorkopf","html_url":"https://github.com/gschorkopf","followers_url":"https://api.github.com/users/gschorkopf/followers","following_url":"https://api.github.com/users/gschorkopf/following{/other_user}","gists_url":"https://api.github.com/users/gschorkopf/gists{/gist_id}","starred_url":"https://api.github.com/users/gschorkopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gschorkopf/subscriptions","organizations_url":"https://api.github.com/users/gschorkopf/orgs","repos_url":"https://api.github.com/users/gschorkopf/repos","events_url":"https://api.github.com/users/gschorkopf/events{/privacy}","received_events_url":"https://api.github.com/users/gschorkopf/received_events","type":"User","site_admin":false},"repo":{"id":17229120,"name":"frolfr","full_name":"gschorkopf/frolfr","owner":{"login":"gschorkopf","id":2623668,"avatar_url":"https://avatars.githubusercontent.com/u/2623668?v=2","gravatar_id":"","url":"https://api.github.com/users/gschorkopf","html_url":"https://github.com/gschorkopf","followers_url":"https://api.github.com/users/gschorkopf/followers","following_url":"https://api.github.com/users/gschorkopf/following{/other_user}","gists_url":"https://api.github.com/users/gschorkopf/gists{/gist_id}","starred_url":"https://api.github.com/users/gschorkopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gschorkopf/subscriptions","organizations_url":"https://api.github.com/users/gschorkopf/orgs","repos_url":"https://api.github.com/users/gschorkopf/repos","events_url":"https://api.github.com/users/gschorkopf/events{/privacy}","received_events_url":"https://api.github.com/users/gschorkopf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gschorkopf/frolfr","description":"Rails and Ember frisbee golf tracker","fork":false,"url":"https://api.github.com/repos/gschorkopf/frolfr","forks_url":"https://api.github.com/repos/gschorkopf/frolfr/forks","keys_url":"https://api.github.com/repos/gschorkopf/frolfr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gschorkopf/frolfr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gschorkopf/frolfr/teams","hooks_url":"https://api.github.com/repos/gschorkopf/frolfr/hooks","issue_events_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/events{/number}","events_url":"https://api.github.com/repos/gschorkopf/frolfr/events","assignees_url":"https://api.github.com/repos/gschorkopf/frolfr/assignees{/user}","branches_url":"https://api.github.com/repos/gschorkopf/frolfr/branches{/branch}","tags_url":"https://api.github.com/repos/gschorkopf/frolfr/tags","blobs_url":"https://api.github.com/repos/gschorkopf/frolfr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gschorkopf/frolfr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gschorkopf/frolfr/git/refs{/sha}","trees_url":"https://api.github.com/repos/gschorkopf/frolfr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gschorkopf/frolfr/statuses/{sha}","languages_url":"https://api.github.com/repos/gschorkopf/frolfr/languages","stargazers_url":"https://api.github.com/repos/gschorkopf/frolfr/stargazers","contributors_url":"https://api.github.com/repos/gschorkopf/frolfr/contributors","subscribers_url":"https://api.github.com/repos/gschorkopf/frolfr/subscribers","subscription_url":"https://api.github.com/repos/gschorkopf/frolfr/subscription","commits_url":"https://api.github.com/repos/gschorkopf/frolfr/commits{/sha}","git_commits_url":"https://api.github.com/repos/gschorkopf/frolfr/git/commits{/sha}","comments_url":"https://api.github.com/repos/gschorkopf/frolfr/comments{/number}","issue_comment_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/comments/{number}","contents_url":"https://api.github.com/repos/gschorkopf/frolfr/contents/{+path}","compare_url":"https://api.github.com/repos/gschorkopf/frolfr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gschorkopf/frolfr/merges","archive_url":"https://api.github.com/repos/gschorkopf/frolfr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gschorkopf/frolfr/downloads","issues_url":"https://api.github.com/repos/gschorkopf/frolfr/issues{/number}","pulls_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls{/number}","milestones_url":"https://api.github.com/repos/gschorkopf/frolfr/milestones{/number}","notifications_url":"https://api.github.com/repos/gschorkopf/frolfr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gschorkopf/frolfr/labels{/name}","releases_url":"https://api.github.com/repos/gschorkopf/frolfr/releases{/id}","created_at":"2014-02-26T23:09:07Z","updated_at":"2014-09-29T20:43:46Z","pushed_at":"2014-10-21T22:07:58Z","git_url":"git://github.com/gschorkopf/frolfr.git","ssh_url":"git@github.com:gschorkopf/frolfr.git","clone_url":"https://github.com/gschorkopf/frolfr.git","svn_url":"https://github.com/gschorkopf/frolfr","homepage":"http://frolfr.com","size":2689,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":13,"forks":2,"open_issues":13,"watchers":2,"default_branch":"master"}},"base":{"label":"gschorkopf:master","ref":"master","sha":"11e765f7997fffeb62601ded75a836b4427ed516","user":{"login":"gschorkopf","id":2623668,"avatar_url":"https://avatars.githubusercontent.com/u/2623668?v=2","gravatar_id":"","url":"https://api.github.com/users/gschorkopf","html_url":"https://github.com/gschorkopf","followers_url":"https://api.github.com/users/gschorkopf/followers","following_url":"https://api.github.com/users/gschorkopf/following{/other_user}","gists_url":"https://api.github.com/users/gschorkopf/gists{/gist_id}","starred_url":"https://api.github.com/users/gschorkopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gschorkopf/subscriptions","organizations_url":"https://api.github.com/users/gschorkopf/orgs","repos_url":"https://api.github.com/users/gschorkopf/repos","events_url":"https://api.github.com/users/gschorkopf/events{/privacy}","received_events_url":"https://api.github.com/users/gschorkopf/received_events","type":"User","site_admin":false},"repo":{"id":17229120,"name":"frolfr","full_name":"gschorkopf/frolfr","owner":{"login":"gschorkopf","id":2623668,"avatar_url":"https://avatars.githubusercontent.com/u/2623668?v=2","gravatar_id":"","url":"https://api.github.com/users/gschorkopf","html_url":"https://github.com/gschorkopf","followers_url":"https://api.github.com/users/gschorkopf/followers","following_url":"https://api.github.com/users/gschorkopf/following{/other_user}","gists_url":"https://api.github.com/users/gschorkopf/gists{/gist_id}","starred_url":"https://api.github.com/users/gschorkopf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gschorkopf/subscriptions","organizations_url":"https://api.github.com/users/gschorkopf/orgs","repos_url":"https://api.github.com/users/gschorkopf/repos","events_url":"https://api.github.com/users/gschorkopf/events{/privacy}","received_events_url":"https://api.github.com/users/gschorkopf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gschorkopf/frolfr","description":"Rails and Ember frisbee golf tracker","fork":false,"url":"https://api.github.com/repos/gschorkopf/frolfr","forks_url":"https://api.github.com/repos/gschorkopf/frolfr/forks","keys_url":"https://api.github.com/repos/gschorkopf/frolfr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gschorkopf/frolfr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gschorkopf/frolfr/teams","hooks_url":"https://api.github.com/repos/gschorkopf/frolfr/hooks","issue_events_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/events{/number}","events_url":"https://api.github.com/repos/gschorkopf/frolfr/events","assignees_url":"https://api.github.com/repos/gschorkopf/frolfr/assignees{/user}","branches_url":"https://api.github.com/repos/gschorkopf/frolfr/branches{/branch}","tags_url":"https://api.github.com/repos/gschorkopf/frolfr/tags","blobs_url":"https://api.github.com/repos/gschorkopf/frolfr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gschorkopf/frolfr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gschorkopf/frolfr/git/refs{/sha}","trees_url":"https://api.github.com/repos/gschorkopf/frolfr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gschorkopf/frolfr/statuses/{sha}","languages_url":"https://api.github.com/repos/gschorkopf/frolfr/languages","stargazers_url":"https://api.github.com/repos/gschorkopf/frolfr/stargazers","contributors_url":"https://api.github.com/repos/gschorkopf/frolfr/contributors","subscribers_url":"https://api.github.com/repos/gschorkopf/frolfr/subscribers","subscription_url":"https://api.github.com/repos/gschorkopf/frolfr/subscription","commits_url":"https://api.github.com/repos/gschorkopf/frolfr/commits{/sha}","git_commits_url":"https://api.github.com/repos/gschorkopf/frolfr/git/commits{/sha}","comments_url":"https://api.github.com/repos/gschorkopf/frolfr/comments{/number}","issue_comment_url":"https://api.github.com/repos/gschorkopf/frolfr/issues/comments/{number}","contents_url":"https://api.github.com/repos/gschorkopf/frolfr/contents/{+path}","compare_url":"https://api.github.com/repos/gschorkopf/frolfr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gschorkopf/frolfr/merges","archive_url":"https://api.github.com/repos/gschorkopf/frolfr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gschorkopf/frolfr/downloads","issues_url":"https://api.github.com/repos/gschorkopf/frolfr/issues{/number}","pulls_url":"https://api.github.com/repos/gschorkopf/frolfr/pulls{/number}","milestones_url":"https://api.github.com/repos/gschorkopf/frolfr/milestones{/number}","notifications_url":"https://api.github.com/repos/gschorkopf/frolfr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gschorkopf/frolfr/labels{/name}","releases_url":"https://api.github.com/repos/gschorkopf/frolfr/releases{/id}","created_at":"2014-02-26T23:09:07Z","updated_at":"2014-09-29T20:43:46Z","pushed_at":"2014-10-21T22:07:58Z","git_url":"git://github.com/gschorkopf/frolfr.git","ssh_url":"git@github.com:gschorkopf/frolfr.git","clone_url":"https://github.com/gschorkopf/frolfr.git","svn_url":"https://github.com/gschorkopf/frolfr","homepage":"http://frolfr.com","size":2689,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":13,"forks":2,"open_issues":13,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23"},"html":{"href":"https://github.com/gschorkopf/frolfr/pull/23"},"issue":{"href":"https://api.github.com/repos/gschorkopf/frolfr/issues/23"},"comments":{"href":"https://api.github.com/repos/gschorkopf/frolfr/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/gschorkopf/frolfr/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/gschorkopf/frolfr/statuses/c7748f98191974d17099dcd573814fe81f201629"}}}}