aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Config.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WebCoso/Config.pm')
-rw-r--r--lib/WebCoso/Config.pm41
1 files changed, 39 insertions, 2 deletions
diff --git a/lib/WebCoso/Config.pm b/lib/WebCoso/Config.pm
index 1b4d6d8..018c3c7 100644
--- a/lib/WebCoso/Config.pm
+++ b/lib/WebCoso/Config.pm
@@ -9,6 +9,8 @@ use utf8;
my @resources;
my $collections=WebCoso::Collections->new();
my %resource_to_pipeline;
+my %name_to_resource;
+my %name_to_collection;
sub read_scalar {
my ($class,$content,$filename)=@_;
@@ -25,9 +27,18 @@ EOF
nested => $@,
);
}
- else {
- return 1;
+ my $symbols=\%WEBCOSO::CONFIG::;
+ for my $name (keys %$symbols) {
+ my $object=${*{$symbols->{$name}}{SCALAR}};
+ my $type=ref($object);
+ if ($type eq 'WebCoso::Resource') {
+ $name_to_resource{$name}=$object;
+ }
+ elsif ($type eq 'WebCoso::Collection') {
+ $name_to_collection{$name}=$object;
+ }
}
+ return 1;
}
sub add_resource {
@@ -39,6 +50,19 @@ sub get_all_resources {
return @resources;
}
+sub get_res_by_name {
+ my ($class,$name)=@_;
+
+ if (exists $name_to_resource{$name}) {
+ return $name_to_resource{$name};
+ }
+ else {
+ WebCoso::X::NoSuchResource->throw(
+ resource => $name
+ );
+ }
+}
+
sub add_collection {
my ($class,$collection)=@_;
$collections->add_collection($collection);
@@ -48,6 +72,19 @@ sub get_collections {
return $collections;
}
+sub get_coll_by_name {
+ my ($class,$name)=@_;
+
+ if (exists $name_to_collection{$name}) {
+ return $name_to_collection{$name};
+ }
+ else {
+ WebCoso::X::NoSuchCollection->throw(
+ collection => $name
+ );
+ }
+}
+
sub get_pipeline_for {
my ($class, $resource)=@_;