From 3a97a2da5c4a5d0e93ec7402440f8321274dcbc2 Mon Sep 17 00:00:00 2001 From: gekka Date: Tue, 18 Oct 2005 17:01:21 +0000 Subject: Aggiunta supporto iniziale Collections git-svn-id: svn://luxion/repos/WebCoso/trunk@4 fcb26f47-9200-0410-b104-b98ab5b095f3 --- lib/WebCoso/Config.pm | 27 +++++++++++++++++++++++++-- lib/WebCoso/Config/Collection.pm | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 lib/WebCoso/Config/Collection.pm (limited to 'lib') 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 ); + +sub BUILD { + my ($self,$ident,$args_ref)=@_; + WebCoso::Config->add_collection($self); +} + +} + +1; -- cgit v1.2.3