Commits

Anonymous committed 75dc1a9

Got rid of _init in RendererBase for some Moose paradigms.

  • Participants
  • Parent commits c21a8e6

Comments (0)

Files changed (3)

File perl/modules/XML-Grammar-Fiction/MANIFEST

 META.yml # Will be created by "make dist"
 README
 rejects/lib/XML/Grammar/Fiction/FromProto/Parser/PRD.pm
+rejects/lib/XML/Grammar/Fiction/RendererBase.pm
 rejects/proto-text-to-xml.t
 rejects/QnD.pm
 t/00-load.t

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/RendererBase.pm

 use XML::LibXML;
 use XML::LibXSLT;
 
-use base 'XML::Grammar::Fiction::Base';
-
 use Moose;
 
-has '_data_dir' => (isa => 'Str', is => 'rw');
-has '_rng' => (isa => 'XML::LibXML::RelaxNG', is => 'rw');
-has '_xml_parser' => (isa => "XML::LibXML", is => 'rw');
-has '_stylesheet' => (isa => "XML::LibXSLT::StylesheetWrapper", is => 'rw');
+has '_data_dir' =>
+(
+    isa => 'Str', 
+    is => 'rw',
+    lazy => 1,
+    init_arg => "data_dir",
+    default => sub {
+        my $self = shift;
+
+        return $self->_get_default_data_dir();
+    },
+);
+has '_rng' =>
+(
+    isa => 'XML::LibXML::RelaxNG', 
+    is => 'rw',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+
+        return $self->_get_rng_schema();
+    },
+);
+
+has '_xml_parser' => 
+(
+    isa => "XML::LibXML", 
+    is => 'rw',
+    lazy => 1,
+    default => sub {
+        return XML::LibXML->new();
+    },
+);
+
+has '_stylesheet' => 
+(
+    isa => "XML::LibXSLT::StylesheetWrapper", 
+    is => 'rw',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+
+        return $self->_get_stylesheet();
+    },
+);
 
 =head1 NAME
 
     return $xslt->parse_stylesheet($style_doc);
 }
 
-sub _init
-{
-    my ($self, $args) = @_;
 
-    $self->_data_dir($args->{'data_dir'} || $self->_get_default_data_dir());
-
-    $self->_rng($self->_get_rng_schema());
-
-    $self->_xml_parser(XML::LibXML->new());
-
-    $self->_stylesheet($self->_get_stylesheet());
-
-    return 0;
-}
 
 =head2 generic_translate
 

File perl/modules/XML-Grammar-Fiction/rejects/lib/XML/Grammar/Fiction/RendererBase.pm

+package XML::Grammar::Fiction::RendererBase;
+
+use strict;
+use warnings;
+
+sub _init
+{
+    my ($self, $args) = @_;
+
+    $self->_data_dir($args->{'data_dir'} || $self->_get_default_data_dir());
+
+    $self->_rng($self->_get_rng_schema());
+
+    $self->_xml_parser(XML::LibXML->new());
+
+    $self->_stylesheet($self->_get_stylesheet());
+
+    return 0;
+}
+
+1;
+