Created
May 12, 2012 21:01
-
-
Save possibilities/2669018 to your computer and use it in GitHub Desktop.
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
if (Meteor.is_client) { | |
Template.beastie.resultOfSabatage = function () { | |
return Session.get('resultOfSabatage'); | |
}; | |
var handleResults = function(err, result) { | |
if (err) { | |
Session.set('resultOfSabatage', 'Failure! (' + err.error + ')'); | |
} else { | |
Session.set('resultOfSabatage', 'Success!'); | |
} | |
}; | |
Template.beastie.events = { | |
'click .yauch' : function () { | |
Meteor.call('sabatage', { user: 'yauch' }, handleResults); | |
}, | |
'click .bob' : function () { | |
Meteor.call('sabatage', { user: 'bob' }, handleResults); | |
} | |
}; | |
} | |
if (Meteor.is_server) { | |
Meteor.methods({ | |
sabatage: function(args) { | |
return args.user; | |
} | |
}); | |
var checkIsABeastieBoyFilter = function(args) { | |
if (!_.contains(['yauch', 'horovitz', 'diamond'], args.user)) { | |
throw new Meteor.Error('If I knew it was gonna be this kinda party I woulda stuck my dick in the mashed potatoes!'); | |
} | |
return args.user; | |
}; | |
Filter.methods([ | |
checkIsABeastieBoyFilter, { | |
only: 'sabatage' | |
} | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment