aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Resource.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WebCoso/Resource.pm')
-rw-r--r--lib/WebCoso/Resource.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/WebCoso/Resource.pm b/lib/WebCoso/Resource.pm
index 29146f2..077c577 100644
--- a/lib/WebCoso/Resource.pm
+++ b/lib/WebCoso/Resource.pm
@@ -2,6 +2,8 @@ package WebCoso::Resource;
use strict;
use warnings;
use Class::Std;
+use Scalar::Util 'weaken';
+use List::MoreUtils 'any';
#use WebCoso::X;
#use Smart::Comments;$Data::Dumper::Useqq=1;
@@ -9,6 +11,7 @@ use Class::Std;
my %values_of :ATTR(:default<{}>);
my %propnames_of :ATTR(:default<{}>);
my %axes_of :ATTR(:default<{}>);
+my %collections_of :ATTR(:get<collections_ref> :default<[]>);
sub get_axes {
my ($self)=@_;
@@ -67,6 +70,27 @@ sub get_property {
return;
}
+sub get_collections {
+ my ($self)=@_;
+
+ return @{ $self->get_collections_ref() };
+}
+
+sub add_coll {
+ my ($self, $collection)=@_;
+
+ return if any { $_ eq $collection } @{ $self->get_collections_ref() };
+
+ my $weak_collection = $collection;
+ weaken $weak_collection;
+
+ push @{ $self->get_collections_ref() }, $weak_collection;
+
+ $collection->add_res($self);
+
+ return;
+}
+
sub _populate_axes_from {
my ($self,$axes_spec)=@_;