stop saving duplicate path arrays in witnesses; get rid of relationship
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Relationship.pm
1 package Text::Tradition::Collation::Relationship;
2
3 use Moose;
4 use Moose::Util::TypeConstraints;
5 ## CAREFUL in our use of Moose::Util::TypeConstraints.  That 'from'
6 ## clashes with Graph::Easy::Edge 'from', so we'll need to unimport
7 ## TypeConstraints after defining the types.  Or else we would have to
8 ## finally split out our types into another module.
9 use MooseX::NonMoose;
10
11 extends 'Graph::Easy::Edge';
12
13 enum 'RelationshipType' => qw( spelling orthographic grammatical repetition lexical );
14
15 no Moose::Util::TypeConstraints;  ## see comment above
16                    
17 has 'type' => (
18     is => 'rw',
19     isa => 'RelationshipType',
20     required => 1,
21 );
22
23 has 'global' => (
24     is => 'rw',
25     isa => 'Bool',
26     default => 0,
27 );
28
29 has 'non_correctable' => (
30     is => 'rw',
31     isa => 'Bool',
32     );
33
34 has 'non_independent' => (
35     is => 'rw',
36     isa => 'Bool',
37     );
38     
39 has 'equal_rank' => (
40     is => 'rw',
41     isa => 'Bool',
42     );
43
44 sub FOREIGNBUILDARGS {
45     my $class = shift;
46     my %args = @_;
47
48     # Make the label match our 'type' attribute.
49     my @superclass_args;
50     if( exists $args{'type'} ) {
51         push( @superclass_args, 'label', $args{'type'} );
52     }
53     return @superclass_args;
54 }
55
56 sub BUILD {
57     my( $self, $args ) = @_;
58
59     $self->set_attribute( 'class', 'relationship' );
60
61 }
62
63 no Moose;
64 __PACKAGE__->meta->make_immutable;