diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/WebCoso/Config.pm | 27 | ||||
-rw-r--r-- | lib/WebCoso/Config/Collection.pm | 17 |
2 files changed, 42 insertions, 2 deletions
diff --git a/lib/WebCoso/Config.pm b/lib/WebCoso/Config.pm index 68968da..d339bed 100644 --- a/lib/WebCoso/Config.pm +++ b/lib/WebCoso/Config.pm @@ -1,7 +1,9 @@ package WebCoso::Config; use strict; use warnings; -use vars '@resources'; + +my @resources; +my @collections; sub read_scalar { my ($class,$content,$filename)=@_; @@ -28,13 +30,27 @@ sub get_all_resources { return @resources; } +sub add_collection { + my ($class,$collection)=@_; + push @collections,$collection; +} + +sub get_all_collections { + return @collections; +} + +sub clear { + @resources=(); +} + package WebCoso::Config::Helpers; use Path::Class; use WebCoso::Config::Resource; +use WebCoso::Config::Collection; use Exporter::Lite; use vars qw($FILENAME @EXPORT); -@EXPORT=qw(res); +@EXPORT=qw(res coll); sub res { my $dest_filename=pop @_; @@ -55,4 +71,11 @@ sub res { }); } +sub coll { + my ($name)=@_; + WebCoso::Config::Collection->new({ + name=>$name, + }); +} + 1; diff --git a/lib/WebCoso/Config/Collection.pm b/lib/WebCoso/Config/Collection.pm new file mode 100644 index 0000000..4b27026 --- /dev/null +++ b/lib/WebCoso/Config/Collection.pm @@ -0,0 +1,17 @@ +package WebCoso::Config::Collection; +use strict; +use warnings; +use Class::Std; +use WebCoso::Config; + +{ +my %name_of :ATTR( :init_arg<name> ); + +sub BUILD { + my ($self,$ident,$args_ref)=@_; + WebCoso::Config->add_collection($self); +} + +} + +1; |