Last active
August 29, 2015 14:04
-
-
Save heymichaelp/c7465add51643edaf4bd to your computer and use it in GitHub Desktop.
Decorators: Example Service Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('underscore') | |
var GenerateReportCard = function(student) { | |
this.student = student | |
}; | |
GenerateReportCard.prototype = _.extend(GenerateReportCard.prototype, { | |
run: function() { | |
return _.compose( | |
this.saveReportCardAsPDF, | |
this.generateReportCardHtml, | |
this.getStudentGrade | |
).call(this) | |
}, | |
getStudentGrade: function() { | |
// some actions here to | |
// determine grade | |
return grade | |
}, | |
generateReportCardHtml: function(grade) { | |
// some actions here to | |
// build html for report card | |
return html | |
}, | |
saveReportCardAsPDF: function(html) { | |
// some actions here to | |
// save PDF and get the url | |
return pdfUrl | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment