[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to alias only one time, in an eval string.

trebor777

12/1/2007 6:21:00 PM


I'm using a software which use compressed ruby scripts... For that, the
software load the uncompressed data and eval it.
In this software, you have the ability to reset the execution, and basically
it eval again all the uncompressed data.

The thing is... when you alias some methods from specific classes defined by
the software and not by the compressed scripts, it cause a stack error, as
aliased method are then on the second time refering to themselves:

alias b a
def a
do somethin
b
end

1st time ok,
but at the second time , a use b which refer to a which use b, etc.. etc..
I'm trying to check if the aliased method exist or not, but doesn't work for
a stange reason...

The main problem is I don't have any access to those Specific classes, or do
stuff before the eval.
I've tried to modify the alias method, but off course, it creates the same
problem but with this method.

any solution?


--
View this message in context: http://www.nabble.com/How-to-alias-only-one-time%2C-in-an-eval-string.-tf4929098.html...
Sent from the ruby-talk mailing list archive at Nabble.com.


1 Answer

ara.t.howard

12/1/2007 6:57:00 PM

0


On Dec 1, 2007, at 11:20 AM, trebor777 wrote:

> alias b a
> def a
> do somethin
> b
> end
>
> 1st time ok,
> but at the second time , a use b which refer to a which use b,
> etc.. etc..
> I'm trying to check if the aliased method exist or not, but doesn't
> work for
> a stange reason...
>
> The main problem is I don't have any access to those Specific
> classes, or do
> stuff before the eval.
> I've tried to modify the alias method, but off course, it creates
> the same
> problem but with this method.
>
> any solution?

wrapped =
begin
method 'b'
true
rescue NameError
false
end

eval code unless wrapped


a @ http://codeforp...
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama