Case: Development environment log level is DEBUG while Production is INFO. I want to use every default log configuration and overwrite only level if environment == develoment.
Problem: first level configs can be over-written but not sub levels.
Consider Example Code:
#file: config.rb
default = Configuration.for('default'){
log {
file '/tmp/foo.log'
level 'WARN'
freq 'daily'
}
}
development = Configuration.for( 'development', default) {
log {
level 'DEBUG'
}
}
In main file, I use the above code like so
# main.rb
require 'config.rb'
$CONFIG = Configuration.for $DEV_ENV # either ('default' || 'development')
p $CONFIG.log.freq
I get an method missing error:
`undefined method `freq' for #<Configuration:0x00000003a65d80> (NoMethodError)`
The only (ugly) solution i have is to point file and freq values back to default like so:
log {
file default.log.file
level 'DEBUG'
freq default.log.freq
}
EEWWW!! Nasty!
Any other suggestions? I've tried to implement something like this with SettingsLogic and Configatron too at no avail. There goes the three top configuration gems for Ruby. Do I need to make my own?? Is this really such an exotic example?
Would love your feedback or suggestions.