X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP%2FRestarter.pm;h=0fffaf0fb4cc1156446378001feee8e750ae7c0a;hb=c03163b837135f3bf3d65380e90b4a68bcc38099;hp=6b1b5f5c54e6fe84a8f83aa470ff7bffd7d1df36;hpb=0fc2d522eec43202c21e9f0062e43f10db4d9008;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/HTTP/Restarter.pm b/lib/Catalyst/Engine/HTTP/Restarter.pm index 6b1b5f5..0fffaf0 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter.pm @@ -1,13 +1,14 @@ package Catalyst::Engine::HTTP::Restarter; - -use Class::C3; use Moose; +use Moose::Util qw/find_meta/; +use namespace::clean -except => 'meta'; + extends 'Catalyst::Engine::HTTP'; -no Moose; use Catalyst::Engine::HTTP::Restarter::Watcher; -sub run { +around run => sub { + my $orig = shift; my ( $self, $class, $port, $host, $options ) = @_; $options ||= {}; @@ -19,6 +20,10 @@ sub run { close STDIN; close STDOUT; + # Best effort if we can't trap compiles.. + $self->_make_components_mutable($class) + if !Catalyst::Engine::HTTP::Restarter::Watcher::DETECT_PACKAGE_COMPILATION(); + my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( directory => ( $options->{restart_directory} || @@ -68,9 +73,21 @@ sub run { } } - return $self->next::method( $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; __END__ @@ -98,11 +115,7 @@ L. =head1 AUTHORS -Sebastian Riedel, - -Dan Kubb, - -Andy Grundman, +Catalyst Contributors, see Catalyst.pm =head1 THANKS