Created
March 22, 2017 16:50
-
-
Save IvanShamatov/de75c636e718c732bfc6c970d13eec9e to your computer and use it in GitHub Desktop.
This file contains 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
class Picture { | |
canAdd() | |
return true | |
} | |
} | |
class ModerationPolicy { | |
canAdd(context) { | |
if( moderated(context)) { | |
return false | |
} else { | |
return context.canAdd(context) | |
} | |
} | |
moderated(picture) { | |
// some state check | |
} | |
} | |
class PictureCollectionPolicy { | |
canAdd(context) { | |
if( picturesLimit()) { | |
return false | |
} else { | |
return context.canAdd(context) | |
} | |
} | |
picturesLimit() { | |
// some state check | |
} | |
} | |
class UserPolicy { | |
canAdd(context) { | |
if( isTeenager() ) { | |
return false | |
} else { | |
return context.canAdd(context) | |
} | |
} | |
isTeenager() { | |
// some state check | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment