Monday, February 21, 2011

dynamic access to constants on ruby

How to verify if the constant is available?
self.const_defined?('DEFAULT_VALUES')

How to call for it: simple way:     MyClass::CONSTANT
Dynamic cool way: MyClass.const_get("CONSTANT")