2008/5/6 GarethAtFlignet <[EMAIL PROTECTED]>:
>
> 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:
>
> class MyClass {
>
> /**
> * @param string $method the name of the called method that did not
> exist.
> * @param array $params an array of parameters passed to the method
> that did not exist.
> */
> public function __call($method, $params) {
>
> }
> }
>
> Any ideas?
You would have to have a __call method (just like in PHP), but
everything would need to go through it.
myJSObj.__call('method', 'param', 'param2', 'param3');
Similar to PHP's call_user_func().
You could also implement a call_user_method which took as the first
param an object and a method name ...
myJSObj.__call({obj:someObj, method:'someMethod'}, 'param1', 'param2');
This would allow you to do static calls also.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---