hook, or override const_set, and const_get

J

John Pywtorak

I have seen some examples of hooking into const_missing; Howerver, I
can't seem to find anything on const_set, and const_get, any ideas?

I tried opening class Module, ex.

class Module
def const_set(cname, cval)
....
end
end

Does not work. I realize this is very dangerous. Is there any other
way to intercept when, ex

FOO="bar"

happens?

Thanks
 
E

Eric Hodel

I have seen some examples of hooking into const_missing; Howerver,
I can't seem to find anything on const_set, and const_get, any ideas?

I tried opening class Module, ex.

class Module
def const_set(cname, cval)
....
end
end

Does not work. I realize this is very dangerous. Is there any
other way to intercept when, ex

FOO="bar"

happens?

a) Edit variable.c

b) Run your code through a ruby2ruby subclass that wraps up your
const assignments with extra code.
 
J

John Pywtorak

Eric said:
a) Edit variable.c

b) Run your code through a ruby2ruby subclass that wraps up your const
assignments with extra code.

Thanks Eric. Option a makes me think I am taking the wrong approach.
Option b looks more attractive. Well at least I know I was not missing
something easier.
 
E

Eric Hodel

Thanks Eric. Option a makes me think I am taking the wrong
approach. Option b looks more attractive. Well at least I know I
was not missing something easier.

Both options are pure evil and guaranteed to cause you pain.

What is your ultimate goal?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top