Created
February 11, 2015 22:52
-
-
Save brunchybit/9cab7b46b5770fb4b141 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
Object::delegates = (methods, to) -> | |
methods.forEach (method) => | |
this::[method] = (args...) -> | |
@[to][method].apply(this, args) | |
class AjaxService | |
start: (target) -> | |
console.log("STARTING AJAX AT #{target}") | |
success: (message) -> | |
console.log("YOU DEED IT #{message}") | |
failure: (error) -> | |
console.log("ERROR MESSAGE WAS #{error}") | |
complete: (done_message) -> | |
console.log("DONE MESSAGE WAS #{done_message}") | |
class Implementor | |
constructor: -> | |
@delegateObject = new AjaxService | |
Implementor.delegates(["start", "success", "failure", "complete"], "delegateObject") | |
i = new Implementor | |
i.start("TELL ME SOME AJAX") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment