-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 15.11.2010 11:02, schrieb niklas | brueckenschlaeger:
> Thank you, but that would only work if the constant isn't defined. Maybe
> I wasn't being clear: I want to override a constant within an object
> with a method.
> 
>   class Bar
>   end
> 
>   class Foo
>     def Bar
>     end
> 
>     def some_method
>       Bar.something # this resolves to constant Bar, not method Bar
>     end
>   end
> 

That should be possible with #send:

class Bar
end

class Foo
  def Bar
  end

  def some_method
    self.send(:Bar).something
  end
end

Not nice to read, but works. But I'm not sure if that meets your
original intention of a convenient method to do it...

Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJM4QmhAAoJEGrS0YjAWTKV12cIAKDMZo7lLCz4QXLolqZ6abdS
BP5yKOuB68IYXBQ6WLTB1EbF/9FNcIIZZ1qGO9CMiThsuX1nPL7uP8Q4sr88pM+Z
rN3dDbcGZ3ZUt+mQHHaTMSW+oWX+rf/DQ5hs/Faaq3QkcPdgupogyaKPVsuWNmto
kktVFoXBxuuQ+I1HNUUaTbvQ2tuClD3rQflUsUJO5d5utLi22KLna6me5dEJuSci
kteL6lpaWqmHp3pCyVR3GODb6fON9IBi2jDHKLjCscIk/DTZWJGxMs7kIeMvPhPY
vxvNSqCMAOtdDKtzg+uKM9O7jXKdZHzC6IqnJoIprAW3HCB4XBZ5Cr/0vt4CVbU=
=ZMgq
-----END PGP SIGNATURE-----