stop saving duplicate path arrays in witnesses; get rid of relationship
[scpubgit/stemmatology.git] / lib / Text / Tradition / Witness.pm
index 5010ffe..dc38c05 100644 (file)
@@ -65,15 +65,10 @@ Accessor method for the witness identifier.
 
 Accessor method for the general witness description.
 
-=head2 path
+=head2 is_layered
 
-An array of Text::Tradition::Collation::Reading objects which, taken in
-sequence, represent the text.
-
-=head2 uncorrected_path
-
-An array of Text::Tradition::Collation::Reading objects which, taken in
-sequence, represent the text before any scribal corrections were made.
+Boolean method to note whether the witness has layers (e.g. pre-correction 
+readings) in the collation.
 
 =begin testing
 
@@ -118,18 +113,24 @@ has 'source' => (
        predicate => 'has_source',
        );
 
-# Path.         This is an array of Reading nodes that should mirror the
-# text above.
+# Path.         This is an array of Reading nodes that can be saved during
+# initialization, but should be cleared before saving in a DB.
 has 'path' => (
        is => 'rw',
        isa => 'ArrayRef[Text::Tradition::Collation::Reading]',
        predicate => 'has_path',
+       clearer => 'clear_path',
        );                 
 
 has 'uncorrected_path' => (
        is => 'rw',
        isa => 'ArrayRef[Text::Tradition::Collation::Reading]',
-       predicate => 'has_ante_corr',
+       clearer => 'clear_uncorrected_path',
+       );
+       
+has 'is_layered' => (
+       is => 'rw',
+       isa => 'Bool',
        );
 
 # Manuscript name or similar
@@ -144,6 +145,14 @@ has 'other_info' => (
        isa => 'Str',
        );
        
+# If we set an uncorrected path, ever, remember that we did so.
+around 'uncorrected_path' => sub {
+       my $orig = shift;
+       my $self = shift;
+       
+       $self->is_layered( 1 );
+       $self->$orig( @_ );
+};
 
 sub BUILD {
        my $self = shift;
@@ -202,6 +211,7 @@ around text => sub {
        $self->$orig( @_ );
 };
 
+
 no Moose;
 __PACKAGE__->meta->make_immutable;