clustericious / Clustericious

2 stars 3 forks source link

Change the way Clustericious::Config defines defaults #22

Closed plicease closed 6 years ago

plicease commented 8 years ago

The way it works now is dumb.

package MyApp;
...
  my $value = $config->foo(default => "value");
...

This means that you need to include the default each place in the code where you want to query for foo.

One way to handle this is to have a default config defined in Clustericious/App.pm and YourApp.pm in YAML/Mojo::Template format, leveraging something like extends_config.

package MyApp;
...
  my $value = $config->foo;
...
__DATA__

---
foo: value

The other way to do it is with a class method returning a hash.

package MyApp;

sub defaults { { foo => "value" } }

...
  my $value = $config->foo;
...

the old default mechanism should work with a deprecation warning for at least a few months.