/[Frey]/trunk/lib/Frey/Config.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Config.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 322 by dpavlin, Thu Nov 6 17:56:59 2008 UTC revision 438 by dpavlin, Wed Nov 19 01:32:36 2008 UTC
# Line 1  Line 1 
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/;
# Line 22  or C<etc/Foo/Bar.yml> has Line 24  or C<etc/Foo/Bar.yml> has
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    
# Line 35  our %config; Line 37  our %config;
37    
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 ) {
# Line 43  sub load_config { Line 46  sub load_config {
46                  } else {                  } else {
47                          %config = %{ merge( LoadFile($path) , \%config ) } if -e $path;                          %config = %{ merge( LoadFile($path) , \%config ) } if -e $path;
48                  }                  }
49                  warn "## $path current config = ",dump( %config ) if $self->debug;                  warn "## load_config $path current config = ",dump( %config ) if $self->debug;
50          }          }
51  }  }
52    

Legend:
Removed from v.322  
changed lines
  Added in v.438

  ViewVC Help
Powered by ViewVC 1.1.26