1 |
package Frey::Config; |
package Frey::Config; |
2 |
use Moose::Role; |
use Moose::Role; |
3 |
|
|
4 |
|
#requires 'debug'; |
5 |
|
|
6 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
7 |
use Hash::Merge qw/merge/; |
use Hash::Merge qw/merge/; |
8 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
24 |
|
|
25 |
baz: 42 |
baz: 42 |
26 |
|
|
27 |
You can also force config re-load with |
You can also force config reload with |
28 |
|
|
29 |
Foo::Bar->load_config('custom'); |
Foo::Bar->load_config('custom'); |
30 |
|
|
35 |
|
|
36 |
our %config; |
our %config; |
37 |
|
|
|
sub debug { 1 }; |
|
|
|
|
38 |
sub load_config { |
sub load_config { |
39 |
my $self = shift; |
my $self = shift; |
40 |
|
%config = (); |
41 |
foreach my $name ( 'config', 'site_config', ref($self), @_ ) { |
foreach my $name ( 'config', 'site_config', ref($self), @_ ) { |
42 |
my $path = "etc/$name.yml"; |
my $path = "etc/$name.yml"; |
43 |
if ( $path =~ s{::}{/}g ) { |
if ( $path =~ s{::}{/}g ) { |
60 |
return $config{ $key }; |
return $config{ $key }; |
61 |
} |
} |
62 |
|
|
63 |
|
no Moose::Role; |
64 |
|
|
65 |
1; |
1; |