diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/WebCoso/Config.pm | 1 | ||||
-rw-r--r-- | lib/WebCoso/Config/Collection.pm | 39 | ||||
-rw-r--r-- | lib/WebCoso/Config/Resource.pm | 12 |
3 files changed, 46 insertions, 6 deletions
diff --git a/lib/WebCoso/Config.pm b/lib/WebCoso/Config.pm index d339bed..74c150b 100644 --- a/lib/WebCoso/Config.pm +++ b/lib/WebCoso/Config.pm @@ -41,6 +41,7 @@ sub get_all_collections { sub clear { @resources=(); + @collections=(); } package WebCoso::Config::Helpers; diff --git a/lib/WebCoso/Config/Collection.pm b/lib/WebCoso/Config/Collection.pm index 4b27026..6b5d201 100644 --- a/lib/WebCoso/Config/Collection.pm +++ b/lib/WebCoso/Config/Collection.pm @@ -5,13 +5,50 @@ use Class::Std; use WebCoso::Config; { -my %name_of :ATTR( :init_arg<name> ); +my %names_of :ATTR( :get<names> ); sub BUILD { my ($self,$ident,$args_ref)=@_; + + my $names=$args_ref->{name}; + # trasformo un nome semplice in un nome "per qualsiasi lingua" + $names={''=>$names} unless ref($names) eq 'HASH'; + $names_of{$ident}=$names; + WebCoso::Config->add_collection($self); } +sub axes { + return 'language'; +} + +sub axis { + my ($self,$axis_name)=@_; + if ($axis_name eq 'language') { + return keys %{ $self->get_names() } + } + else { + return; + } +} + +sub properties { + my ($self,$axis_name,$axis_value,@rest)=@_; + + if (@rest==0 and $axis_name eq 'language') { + if ( grep { $_ eq $axis_value } + keys %{ $self->get_names() } + ) { + return { + name => $self->get_names()->{$axis_value} + }; + } + else { + return; + } + } +} + } 1; diff --git a/lib/WebCoso/Config/Resource.pm b/lib/WebCoso/Config/Resource.pm index b499fec..4b5cd60 100644 --- a/lib/WebCoso/Config/Resource.pm +++ b/lib/WebCoso/Config/Resource.pm @@ -6,9 +6,9 @@ use WebCoso::Config; { -my %sources_of :ATTR( :init_arg<source> ); -my %pipelines_of :ATTR( :init_arg<pipeline> ); -my %dest_of :ATTR( :init_arg<destination> ); +my %sources_of :ATTR( :init_arg<source> :get<sources>); +my %pipelines_of :ATTR( :init_arg<pipeline> :get<pipeline>); +my %dest_of :ATTR( :init_arg<destination> :get<destination>); sub BUILD { my ($self,$ident,$args_ref)=@_; @@ -22,7 +22,7 @@ sub axes { sub axis { my ($self,$axis_name)=@_; if ($axis_name eq 'filename') { - return @{$sources_of{ident($self)}}; + return @{ $self->get_sources() }; } else { return; @@ -32,7 +32,9 @@ sub axis { sub datastream { my ($self,$axis_name,$axis_value,@rest)=@_; if (@rest==0 and $axis_name eq 'filename') { - if ( grep { $_ eq $axis_value } @{$sources_of{ident($self)}} ) { + if ( grep { $_ eq $axis_value } + @{ $self->get_sources() } + ) { return _read_file($axis_value); } } |