Commit | Line | Data |
d047cd52 |
1 | package Text::Tradition::Collation::Relationship; |
2 | |
3 | use Moose; |
4 | use Moose::Util::TypeConstraints; |
3265b0ce |
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; |
d047cd52 |
10 | |
3265b0ce |
11 | extends 'Graph::Easy::Edge'; |
d047cd52 |
12 | |
ef9d481f |
13 | enum 'RelationshipType' => qw( spelling orthographic grammatical repetition lexical ); |
3265b0ce |
14 | |
3265b0ce |
15 | no Moose::Util::TypeConstraints; ## see comment above |
16 | |
4cdd82f1 |
17 | has 'type' => ( |
d047cd52 |
18 | is => 'rw', |
19 | isa => 'RelationshipType', |
20 | required => 1, |
21 | ); |
22 | |
d047cd52 |
23 | has 'global' => ( |
24 | is => 'rw', |
25 | isa => 'Bool', |
3265b0ce |
26 | default => 0, |
d047cd52 |
27 | ); |
28 | |
b15511bf |
29 | has 'non_correctable' => ( |
30 | is => 'rw', |
31 | isa => 'Bool', |
32 | ); |
33 | |
34 | has 'non_independent' => ( |
35 | is => 'rw', |
36 | isa => 'Bool', |
37 | ); |
910a0a6d |
38 | |
39 | has 'equal_rank' => ( |
40 | is => 'rw', |
41 | isa => 'Bool', |
42 | ); |
b15511bf |
43 | |
3265b0ce |
44 | sub FOREIGNBUILDARGS { |
45 | my $class = shift; |
46 | my %args = @_; |
47 | |
4cdd82f1 |
48 | # Make the label match our 'type' attribute. |
3265b0ce |
49 | my @superclass_args; |
4cdd82f1 |
50 | if( exists $args{'type'} ) { |
51 | push( @superclass_args, 'label', $args{'type'} ); |
3265b0ce |
52 | } |
53 | return @superclass_args; |
54 | } |
55 | |
56 | sub BUILD { |
57 | my( $self, $args ) = @_; |
58 | |
59 | $self->set_attribute( 'class', 'relationship' ); |
60 | |
3265b0ce |
61 | } |
62 | |
63 | no Moose; |
64 | __PACKAGE__->meta->make_immutable; |