Skip to content

Instantly share code, notes, and snippets.

@rschmukler
Created September 21, 2013 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rschmukler/6646743 to your computer and use it in GitHub Desktop.
Save rschmukler/6646743 to your computer and use it in GitHub Desktop.
var extend = require('extend');
module.exports = function(Track) {
Track.present = {
forSmallApi: { plays: 0, comments: 0, updatedAt: 0, hearts: 0 }
};
Track.on('initialize', function(instance) {
var presenter = {
smallApiSummary: function(user) {
var hearted = false;
if(user) {
hearted = hasUserHeartedTrack(user, instance);
}
return extend(instance.filter([
'plays', 'comments', 'updatedAt', 'hearts'
]), {
hearted: hearted
});
},
largeApi: function(user) {
var hearted = false;
if(user) {
hearted = hasUserHeartedTrack(user, instance);
}
return extend(instance.filter(), {
hearted: hearted
});
}
};
instance.present = function() {
return presenter;
};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment