diff options
| author | franck cuny <franck@lumberjaph.net> | 2010-07-16 11:19:15 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2010-07-16 11:19:15 +0200 |
| commit | faf6949033a021bffab3c91a04665efef4378b28 (patch) | |
| tree | 48f04f0f373f3c2067216d76eaeb9f0e4badf339 /lib/Graph/GEXF/Role/Attributes.pm | |
| download | graph-gexf-faf6949033a021bffab3c91a04665efef4378b28.tar.gz | |
basic gexf generation
Diffstat (limited to '')
| -rw-r--r-- | lib/Graph/GEXF/Role/Attributes.pm | 35 |
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; |
