summaryrefslogtreecommitdiff
path: root/lib/Graph/GEXF/Role/Attributes.pm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/Graph/GEXF/Role/Attributes.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Graph/GEXF/Role/Attributes.pm b/lib/Graph/GEXF/Role/Attributes.pm
new file mode 100644
index 0000000..644793d
--- /dev/null
+++ b/lib/Graph/GEXF/Role/Attributes.pm
@@ -0,0 +1,35 @@
+package Graph::GEXF::Role::Attributes;
+
+use MooseX::Role::Parameterized;
+
+parameter for => (
+ is => 'ro',
+ required => 1,
+);
+
+role {
+ my $p = shift;
+
+ foreach my $type (@{$p->for}) {
+
+ my $attr_name = $type . '_attributes';
+
+ has $attr_name => (
+ traits => ['Hash'],
+ is => 'rw',
+ isa => 'HashRef',
+ lazy => 1,
+ default => sub { {} },
+ handles => {
+ 'attributes_' . $type . '_total' => 'count',
+ 'set_' . $type . '_attribute' => 'set',
+ 'get_' . $type . '_attribute' => 'get',
+ 'attributes_' . $type . '_list' => 'keys',
+ 'has_'.$type.'_attribute' => 'exists',
+ }
+ );
+ }
+
+};
+
+1;