Skip to content

Instantly share code, notes, and snippets.

@possibilities
Created May 12, 2012 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save possibilities/2669018 to your computer and use it in GitHub Desktop.
Save possibilities/2669018 to your computer and use it in GitHub Desktop.
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