I store the value in a class variable inside the module, for example:
module TranslationEnhancer def self.install! klass @dictionaries ||= [] << klass end ... end
I call this from the initializer in config / initializers:
require Rails.root + "lib" + "translation_enhancer.rb" TranslationEnhancer::install! TranslationDictionary
Now, if I start the server in the development environment, everything is fine during the first request. However, after this request, @ dictionaries are suddenly gone. I commented on all the other code in TranslationEnhancer, so I am absolutely sure that the whole module should be reloaded every time I make a request.
I tried to move the module outside of the lib directory (moved it to lib_unloadable), and then tried:
ActiveSupport::Dependencies.explicitly_unloadable_constants << "TranslationEnhancer"
but again failed. I do not know how to solve this, please help.
Got Ruby 1.9.2 @Rails 3.1.rc4.
EDIT: I know that I could set dictionaries as a constant. But I would like to use TranslationEnhancer as a library, so I could use it unchanged in another project and install different directories, for example:
TranslationEnhancer.install! EnglishDirectory, FrenchDirectory
These values will change at runtime; they simply change the project to project.