T
T. Sawyer
I'm stumped. Is there any way to do this?
class Object
def self.const_missing(name)
p self # => X
# Okay, but how do I get at object x?
x = ?
if x.respond_to?myconstant)
return "Gotchya"
else
raise # proper error?
end
end
end
class X
def myconstant
puts NewConstant
end
end
x = X.new
x.myconstant
Thanks,
T.
class Object
def self.const_missing(name)
p self # => X
# Okay, but how do I get at object x?
x = ?
if x.respond_to?myconstant)
return "Gotchya"
else
raise # proper error?
end
end
end
class X
def myconstant
puts NewConstant
end
end
x = X.new
x.myconstant
Thanks,
T.