MooseX::SymmetricAttribute - Symmetric Moose Attributes -- automatically update inverse attribute
version 0.002
package Foo; use Moose; has bar => ( is => 'rw', isa => 'Bar', ); with 'MooseX::SymmetricAttribute' => { attributes => { bar => 'foo' } }; package Bar; use Moose; has foo => ( is => 'rw', isa => 'Foo', ); package main; my $bar = Bar->new; my $foo = Foo->new; $foo->bar( $bar ); $bar->foo == $foo # true
Use this role to update both attributes in a symmetric relationship by setting one value.
To use it, compose the role into your class like this:
with 'MooseX::SymmetricAttribute' => { attributes => { my_attribute_name_1 => foreign_attribute_name_1, my_attribute_name_2 => foreign_attribute_name_2, } };
If the foreign attribute is an ArrayRef or a Set::Object, the new value will be appended.
This is alpha quality software. There may be some bugs lingering in here, probably some race conditions too. Patches and tests are very welcome!
Gerhard Gossen
This software is copyright (c) 2010 by Gerhard Gossen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::SymmetricAttribute, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::SymmetricAttribute
CPAN shell
perl -MCPAN -e shell install MooseX::SymmetricAttribute
For more information on module installation, please visit the detailed CPAN module installation guide.