mercredi 6 mai 2015

Override/redefine Meteor methods

Is it possible to somehow override a method in Meteor? Or define another function such that both will get called?

I ran into this when I was writing tests and wanted to confirm that emails are being sent. So I thought I could just have a method in tests with the same name that override/duplicates the method.

In my regular code:

Meteor.methods(
   email: (parameters) ->
      sendAnEmail(parameters)
)

In tests:

Meteor.methods(
   email: (parameters) ->
      differentBehaviorForTesting(parameters)
      # I could call some super() here if it existed
)

But this always gets me a

Error: A method named 'email' is already defined

Aucun commentaire:

Enregistrer un commentaire