There could be a case when some config inherited from Anyway::Config (e.g., MyConfig < Anyway::Config) will be instantiated before Rails finished the initialization process. The only caveat here is that when I call MyConfig.new - inside there is a call #load_from_secrets which will ask Rails.application.secrets.
If that call happens before Rails finished initialization (e.g., during require of my gem) we could end up with broken Rails.application.secrets, here is why.
Inside Rails that method (#secrets) has memoization and read all the data only once, but secret_token and secret_key_base could be not yet loaded to config.
I suggest resetting the @secrets instance variable of Rails.application if Rails has not finished initialization yet. Otherwise, we'll have a pretty hard debugging case.
There could be a case when some config inherited from Anyway::Config (e.g., MyConfig < Anyway::Config) will be instantiated before Rails finished the initialization process. The only caveat here is that when I call
MyConfig.new
- inside there is a call#load_from_secrets
which will ask Rails.application.secrets. If that call happens before Rails finished initialization (e.g., during require of my gem) we could end up with broken Rails.application.secrets, here is why.Inside Rails that method (#secrets) has memoization and read all the data only once, but secret_token and secret_key_base could be not yet loaded to config.
I suggest resetting the
@secrets
instance variable of Rails.application if Rails has not finished initialization yet. Otherwise, we'll have a pretty hard debugging case.