summaryrefslogblamecommitdiff
path: root/lib/Graph/GEXF/Role/Attributes.pm
blob: 644793d7f9660a607cee122c1d2ab99a8fe4355b (plain) (tree)


































                                                            
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;