X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP%2FRestarter.pm;h=57ca54a09c068951fd6b863838a170ddfba21c4a;hb=7d9921b1634786926b83a7c9de0dafc69ad506d7;hp=02c58bac82f05202b44e971c41be1669916033cf;hpb=9c71d51daf53bfd6f77d7e252b594392bd4be3de;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP/Restarter.pm b/lib/Catalyst/Engine/HTTP/Restarter.pm index 02c58ba..57ca54a 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter.pm @@ -1,12 +1,14 @@ package Catalyst::Engine::HTTP::Restarter; +use Moose; +use Moose::Util qw/find_meta/; +use namespace::clean -except => 'meta'; + +extends 'Catalyst::Engine::HTTP'; -use strict; -use warnings; -use base 'Catalyst::Engine::HTTP'; use Catalyst::Engine::HTTP::Restarter::Watcher; -use NEXT; -sub run { +around run => sub { + my $orig = shift; my ( $self, $class, $port, $host, $options ) = @_; $options ||= {}; @@ -18,6 +20,8 @@ sub run { close STDIN; close STDOUT; + $self->_make_components_mutable($class); + my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( directory => ( $options->{restart_directory} || @@ -67,7 +71,19 @@ sub run { } } - return $self->NEXT::run( $class, $port, $host, $options ); + return $self->$orig( $class, $port, $host, $options ); +}; + +# Naive way of trying to avoid Moose blowing up when you re-require components +# which have been made immutable. +sub _make_components_mutable { + my ($self, $class) = @_; + + my @metas = map { find_meta(@_) } ($class, map { blessed($_) } values %{ $class->components }); + + foreach my $meta (@metas) { + $meta->make_mutable if $meta->is_immutable; + } } 1; @@ -97,11 +113,7 @@ L. =head1 AUTHORS -Sebastian Riedel, - -Dan Kubb, - -Andy Grundman, +Catalyst Contributors, see Catalyst.pm =head1 THANKS