Commits

Anonymous committed fc41312

Convert the ${event}S field accesses to accessors.

Comments (0)

Files changed (3)

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/Event.pm

 use XML::Grammar::Fiction::FromProto::Nodes;
 
 has 'type' => (isa => "Str", is => "ro");
-has 'tag' => (isa => "Maybe[Str]", is => "ro");
+has 'tag' => (isa => "Maybe[Str]", is => "ro", predicate => '_has_tag',);
 has 'elem' => (isa => "Maybe[XML::Grammar::Fiction::FromProto::Node]", is => "ro");
 has 'tag_elem' => (isa => "Maybe[XML::Grammar::Fiction::FromProto::Node]", is => "ro");
 
+sub is_tag_of_name
+{
+    my ($self, $name) = @_;
+
+    return ($self->_has_tag() && ($self->tag() eq $name));
+}
+
 1;
 
+=head2 $event->is_tag_of_name($name)
+
+Determines if the $event is a tag and of name $name.
+
 =head2 $self->meta()
 
 Leftover from Moose.

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto/Parser/XmlIterator.pm

 {
     my ($self, $event) = @_;
 
-    return exists($event->{'tag'}) && ($event->{'tag'} eq "saying");
+    return $event->is_tag_of_name("saying");
 }
 
 sub _is_event_a_para
 {
     my ($self, $event) = @_;
 
-    return exists($event->{'tag'}) && ($event->{'tag'} eq "para");
+    return $event->is_tag_of_name("para");
 }
 
 sub _is_event_elem
 {
     my ($self, $event) = @_;
 
-    return $event->{'type'} eq "elem";
+    return $event->type() eq "elem";
 }
 
 sub _handle_paragraph_event
     my ($self, $event) = @_;
 
     return
-          $event->{'type'} eq "open"
+          $event->type() eq "open"
         ? $self->_handle_open_para($event)
         : $self->_handle_close_para($event)
         ;
 {
     my ($self, $event) = @_;
 
-    $self->_add_to_top_tag( $event->{'elem'});
+    $self->_add_to_top_tag( $event->elem());
 
     return;
 }

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Screenplay/FromProto/Parser/QnD.pm

     my ($self, $event) = @_;
 
     return
-        $event->{'type'} eq "open"
+        $event->type() eq "open"
         ? $self->_open_saying($event)
         : $self->_close_saying();
 }