[Catalyst-commits] r6296 -
branches/Catalyst-View-TT-nothingmuch_constructor_refactoring/lib/Catalyst/View
nothingmuch at dev.catalyst.perl.org
nothingmuch at dev.catalyst.perl.org
Wed Apr 18 13:41:13 GMT 2007
Author: nothingmuch
Date: 2007-04-18 13:41:13 +0100 (Wed, 18 Apr 2007)
New Revision: 6296
Modified:
branches/Catalyst-View-TT-nothingmuch_constructor_refactoring/lib/Catalyst/View/TT.pm
Log:
break the constructor into various methods responsible for setting up the config and constructing the template object
Modified: branches/Catalyst-View-TT-nothingmuch_constructor_refactoring/lib/Catalyst/View/TT.pm
===================================================================
--- branches/Catalyst-View-TT-nothingmuch_constructor_refactoring/lib/Catalyst/View/TT.pm 2007-04-18 12:38:22 UTC (rev 6295)
+++ branches/Catalyst-View-TT-nothingmuch_constructor_refactoring/lib/Catalyst/View/TT.pm 2007-04-18 12:41:13 UTC (rev 6296)
@@ -183,15 +183,9 @@
}
}
-sub new {
- my ( $class, $c, $arguments ) = @_;
+sub finalize_config {
+ my ( $self, $config ) = @_;
- my $config = $class->prepare_config( $c, $arguments );
-
- my $self = $class->NEXT::new(
- $c, { %$config },
- );
-
# Set base include paths. Local'd in render if needed
$self->include_path($config->{INCLUDE_PATH});
@@ -205,10 +199,21 @@
my $copy = $self;
Scalar::Util::weaken($copy);
$config->{INCLUDE_PATH} = [ sub { $copy->paths } ];
-
- $self->{template} = $self->construct_template_object($c, $config) || return undef;
+}
+sub new {
+ my ( $class, $c, $arguments ) = @_;
+ my $config = $class->prepare_config( $c, $arguments );
+
+ my $self = $class->NEXT::new(
+ $c, { %$config },
+ );
+
+ $self->finalize_config( $config ); # really more like a BUILD
+
+ $self->template( $self->construct_template_object($c, $config) || return undef );
+
return $self;
}
More information about the Catalyst-commits
mailing list