Commits

Shlomi Fish committed 9531680

Refactoring - extract methods.

Comments (0)

Files changed (2)

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

     return;
 }
 
+sub _write_Element_List
+{
+    my ($self, $elem) = @_;
+
+    foreach my $child (@{$elem->contents()})
+    {
+        $self->_write_elem({elem => $child, });
+    }
+
+    return;
+}
+
 around '_write_elem_obj' => sub {
     my $orig = shift;
     my $self = shift;
+
     my ($args) = @_;
 
     my $elem = $args->{elem};
 
     if ($elem->_short_isa("List"))
     {
-        foreach my $child (@{$elem->contents()})
-        {
-            $self->_write_elem({elem => $child, });
-        }
-
-        return;
+        return $self->_write_Element_List($elem);
     }
     else
     {

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/TagsTree2XML.pm

     }
 }
 
+sub _write_Element_Paragraph
+{
+    my ($self, $elem) = @_;
+
+    return $self->_output_tag_with_childs(
+        {
+            start => [$self->_paragraph_tag()],
+            elem => $elem,
+        },
+    );
+}
+
+sub _write_Element_Element
+{
+    my ($self, $elem) = @_;
+
+    return $self->_write_Element_elem($elem);
+}
+
+sub _write_Element_Comment
+{
+    my ($self, $elem) = @_;
+
+    $self->_writer->comment($elem->text());
+}
+
 sub _write_elem_obj
 {
     my ($self, $args) = @_;
     }
     if ($elem->_short_isa("Paragraph"))
     {
-        $self->_output_tag_with_childs(
-            {
-               start => [$self->_paragraph_tag()],
-                elem => $elem,
-            },
-        );
+        $self->_write_Element_Paragraph($elem);
     }
     elsif ($elem->_short_isa("Element"))
     {
-        $self->_write_Element_elem($elem);
+        $self->_write_Element_Element($elem);
     }
     elsif ($elem->_short_isa("Comment"))
     {
-        $self->_writer->comment($elem->text());
+        $self->_write_Element_Comment($elem);
     }
 
     return;