Today I\'ve stumbled upon a tricky issue with Ruby constants. In our team someone created a module, which is included into multiple models. In our (spec) test output this result
This is only a problem in applications that explicitly reload, like Rails applications.
If the verbosity offends you, you can use unless
as a statement modifier instead:
module LifeCycle
RESET = 'reset' unless const_defined?(:RESET)
end
This leaves a few weak arguments against Avdi's suggestion to only use methods:
If you like Avdi's suggestion enough to ignore these, go with it.