--- trunk/lib/Frey/Config.pm 2008/10/31 23:10:08 221 +++ trunk/lib/Frey/Config.pm 2008/11/19 01:32:36 438 @@ -1,6 +1,8 @@ package Frey::Config; use Moose::Role; +#requires 'debug'; + use YAML qw/LoadFile/; use Hash::Merge qw/merge/; use Data::Dump qw/dump/; @@ -22,7 +24,7 @@ baz: 42 -You can also force config re-load with +You can also force config reload with Foo::Bar->load_config('custom'); @@ -35,6 +37,7 @@ sub load_config { my $self = shift; + %config = (); foreach my $name ( 'config', 'site_config', ref($self), @_ ) { my $path = "etc/$name.yml"; if ( $path =~ s{::}{/}g ) { @@ -43,16 +46,17 @@ } else { %config = %{ merge( LoadFile($path) , \%config ) } if -e $path; } - warn "## $path current config = ",dump( %config ) if $self->debug; + warn "## load_config $path current config = ",dump( %config ) if $self->debug; } } sub config { - my $self = shift; - my $key = shift || ref($self); + my ( $self, $key ) = @_; + $key ||= ref($self); warn "## config $key" if $self->debug; $self->load_config unless defined %config; - confess "$key doesn't exist in config" unless defined $config{ $key }; + #confess "$key doesn't exist in config" unless defined $config{ $key }; + return unless defined $config{ $key }; return $config{ $key }; }