Config.pm 722 B

12345678910111213141516171819202122232425262728293031
  1. package Trog::Config;
  2. use strict;
  3. use warnings;
  4. use feature qw{state};
  5. use Config::Simple;
  6. =head1 Trog::Config
  7. A thin wrapper around Config::Simple which reads the configuration from the appropriate place.
  8. =head2 Trog::Config::get() = Config::Simple
  9. Returns a configuration object that will be used by server.psgi, the data model and Routing modules.
  10. Memoized, so you will need to HUP the children on config changes.
  11. =cut
  12. our $home_cfg = "config/main.cfg";
  13. sub get {
  14. state $cf;
  15. return $cf if $cf;
  16. $cf = Config::Simple->new($home_cfg) if -f $home_cfg;
  17. return $cf if $cf;
  18. $cf = Config::Simple->new('config/default.cfg');
  19. return $cf;
  20. }
  21. 1;