P
pedz
Google tells me to "Please try again"... I apologize if this is a duplicatemessage.
Is there a way to implement the equivalent of the "missing_method" method in Ruby? If you call foo.whatever(args) in Ruby and the whatever method is not defined, then it will call the missing_method method if it is defined passing it "whatever" along with the args.
I realize that I can implement this with defining a function "blah" and then just do foo.blah("whatever", args) but the "blah" is distracting. It is much clearer to call foo.whatever(args). Is there a way to do that in Javascript?
Note, that usually the "whatever" is not a single or even a few possible names but is usually a pattern or a large set such that defining all of them is either not possible until run time or impractical.
Thank you,
pedz
Is there a way to implement the equivalent of the "missing_method" method in Ruby? If you call foo.whatever(args) in Ruby and the whatever method is not defined, then it will call the missing_method method if it is defined passing it "whatever" along with the args.
I realize that I can implement this with defining a function "blah" and then just do foo.blah("whatever", args) but the "blah" is distracting. It is much clearer to call foo.whatever(args). Is there a way to do that in Javascript?
Note, that usually the "whatever" is not a single or even a few possible names but is usually a pattern or a large set such that defining all of them is either not possible until run time or impractical.
Thank you,
pedz