Skip to content

Instantly share code, notes, and snippets.

@chadhietala
Created September 17, 2012 21:39
Show Gist options
  • Select an option

  • Save chadhietala/3739958 to your computer and use it in GitHub Desktop.

Select an option

Save chadhietala/3739958 to your computer and use it in GitHub Desktop.
Contributor Model
App.Contributor = Ember.Object.extend()
App.Contributor.reopenClass
allContributors: []
find: ->
$.ajax
url: 'https://api.github.com/repos/emberjs/ember.js/contributors'
dataType: 'jsonp'
success: (resp) =>
resp.data.forEach ((contributor) =>
@allContributors.addObject App.Contributor.create(contributor)
), this
return @allContributors
findOne: (username) ->
contributor = App.Contributor.create
login: username
$.ajax
url: 'https://api.github.com/repos/emberjs/ember.js/contributors'
dataType: 'jsonp'
context: contributor
success: (resp) ->
@setProperties resp.data.findProperty 'login', username
return contributor
loadMoreDetails: ->
$.ajax
url: 'https://api.github.com/users/%@'.fmt(this.get('login'))
context: this
dataType: 'jsonp'
success: (resp) =>
@setProperties resp.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment