How to access a (shadowed) global function in ruby.

Posted by yngvedh on Stack Overflow See other posts from Stack Overflow or by yngvedh
Published on 2010-04-21T10:02:39Z Indexed on 2010/04/21 10:23 UTC
Read the original article Hit count: 124

Filed under:
|

Hi,

I was wondering how to access a global function fn in ruby from a class which also defined a method fn. I have made a workaround by aliasing the function like so:

def fn
end

class Bar
    alias global_fn fn
    def fn
        # how to access the global fn here without the alias
        global_fn
    end
end

I'm looking for something along the lines of c++'s :: to access global scope but I can't seem to locate any information about it. I guess I don't know specifically what I'm looking for.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about scope