X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoo%2F_Utils.pm;h=6fa6e24e06e20a73ec793e08bf3ccbf5e7758ddb;hb=cf62c98938670cba251cdc299ce194d0cdf694a2;hp=2ee545c392250e93324a608f01d7dfa59b775dc5;hpb=59812c87b1b00da1098f22c77e02db83ff594f22;p=gitmo%2FRole-Tiny.git diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm index 2ee545c..6fa6e24 100644 --- a/lib/Moo/_Utils.pm +++ b/lib/Moo/_Utils.pm @@ -11,6 +11,7 @@ BEGIN { } use strictures 1; +use Module::Runtime qw(require_module); use base qw(Exporter); use Moo::_mro; @@ -23,7 +24,7 @@ sub _install_modifier { my ($into, $type, $name, $code) = @_; if (my $to_modify = $into->can($name)) { # CMM will throw for us if not - { local $@; require Sub::Defer; } + require Sub::Defer; Sub::Defer::undefer_sub($to_modify); } @@ -32,15 +33,13 @@ sub _install_modifier { our %MAYBE_LOADED; -# _load_module is inlined in Role::Tiny - make sure to copy if you update it. - sub _load_module { (my $proto = $_[0]) =~ s/::/\//g; return 1 if $INC{"${proto}.pm"}; # can't just ->can('can') because a sub-package Foo::Bar::Baz # creates a 'Baz::' key in Foo::Bar's symbol table return 1 if grep !/::$/, keys %{_getstash($_[0])||{}}; - { local $@; require "${proto}.pm"; } + require_module($_[0]); return 1; }