'... and we should have an auth username';
ok defined $config->auth->pass, '... and password';
ok 1 - The config serializer should be JSON
ok 2 - ... and we should have an auth username
not ok 3 - ... and password
1..3
Can't locate object method "pass" via package "FauxObject::__ANON__4".
Available methods: password, username
at t/config.t line 16.
# Failed test '... and password'
# at t/config.t line 16.
# Looks like you failed 1 test of 3.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests
Basically, the config hash becomes a read-only collection of objects and if you misspell a hash key (method name), you get a sensible error message and a list of the available methods.
Obviously this only works if the config can be represented as a hashref. If you have config keys which cannot be methods, such as "--foo" or something, you can still reach inside the object $config->{"--foo"}. Note that chaining hash keys works, too ($config->auth->password).
Would this be a reasonable feature for Dancer's config?
If an only if the top level config is a hashref, it's blessed as a "Dancer::Config::Object". It should be transparent for the end-user, yes?
Cheers,
Ovid