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

**URL:** <https://www.ruby-forum.com/t/how-to-alias-only-one-time-in-an-eval-string/121839>\
**Category:** Ruby\
**Created:** [December 1, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/how-to-alias-only-one-time-in-an-eval-string/121839 "2007-12-01T19:20:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![trebor777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@trebor777](https://www.ruby-forum.com/u/trebor777)\
**Post date:** [December 1, 2007, 7:20pm UTC](https://www.ruby-forum.com/t/how-to-alias-only-one-time-in-an-eval-string/121839/1 "2007-12-01T19:20:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![trebor777](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a9adbd/32.png) [@trebor777](https://www.ruby-forum.com/u/trebor777)\
**Post date:** [December 1, 2007, 7:58pm UTC](https://www.ruby-forum.com/t/how-to-alias-only-one-time-in-an-eval-string/121839/2 "2007-12-01T19:58:19Z")

</div>

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

> 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://codeforpeople.com/](http://codeforpeople.com/)
