GarethAtFlignet wrote:
> Hi all,
>
> anyone know if it's possible to imitate the very useful PHP __call()
> method in protoype?
>
> For those who are not familiar with PHP, the __call() method is
> invoked whenever a method on an object is called and the method does
> not exist. For example in PHP:
> ...
>
> Any ideas?
>   
I don't think there is a normal way to do this in JavaScript at all.  
You can catch errors of invoking undefined methods with a  
window.onerror = function(errorString, urlString, lineNo){}  but I don't 
think there is a cross-browser way of resolving the object that 
triggered the error.

What is the use case?  Most of the cases I've use __call() in PHP it is 
to wrap classes that can't be extended; but in JavaScript you can extend 
all classes using object.prototype.

- Ken Snyder


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to