T
Trans
Honestly, alias bugs me to know end. When meta-programming, alias is
notorious for causing problems. Not only is it a keyword (yuk), but it
is inherently static.
Well, it doesn't fix everything of course, but here's a little snip
that came to me today to take some of the static edge off:
class Module
alias _alias_method alias_method
def alias_method(name,target)
begin
_alias_method(name,target)
rescue
module_eval %{
def #{name}(*a,&b)
#{target}(*a,*b)
end
}
end
end
end
Now it's possible to alias a method that's hasn't been defined yet.
T.
notorious for causing problems. Not only is it a keyword (yuk), but it
is inherently static.
Well, it doesn't fix everything of course, but here's a little snip
that came to me today to take some of the static edge off:
class Module
alias _alias_method alias_method
def alias_method(name,target)
begin
_alias_method(name,target)
rescue
module_eval %{
def #{name}(*a,&b)
#{target}(*a,*b)
end
}
end
end
end
Now it's possible to alias a method that's hasn't been defined yet.
T.