Last active
August 29, 2015 14:03
-
-
Save heymichaelp/b2fb4277a2200c7b6768 to your computer and use it in GitHub Desktop.
Policy Objects: Example
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 PassingStudentPolicy = require('./passingStudentPolicy'); | |
var SportsEligibilityPolicy = function(student) { | |
this.student = student; | |
}; | |
SportsEligibilityPolicy.prototype = _.extend(SportsEligibilityPolicy.prototype, { | |
run: function() { | |
return this.isNotExpelled() && this.isNotSuspended() && this.isPassing(); | |
}, | |
isNotExpelled: function() { | |
return this.student.isExpelled !== true; | |
}, | |
isNotSuspended: function() { | |
return this.student.isSuspended !== true; | |
}, | |
isPassing: function() { | |
return new PassingStudentPolicy(this.student).run(); | |
} | |
}); | |
module.exports = SportsEligibilityPolicy; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment