X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FUtil.pm;h=835db2adb7d6c6ba8f8f7132455cecf4bb6409c2;hb=57f0e313f1dbecca6a82ae9dd5ae2c9657d21a4f;hp=e86da70900972e41507d506579831d270e9556b3;hpb=0449307510ab4425a6b340fee9bf85824eb994b1;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Util.pm b/lib/Mouse/Util.pm index e86da70..835db2a 100644 --- a/lib/Mouse/Util.pm +++ b/lib/Mouse/Util.pm @@ -5,6 +5,7 @@ use warnings; use Exporter; use Carp qw(confess); +use B (); use constant _MOUSE_VERBOSE => !!$ENV{MOUSE_VERBOSE}; @@ -22,6 +23,8 @@ our @EXPORT_OK = qw( get_linear_isa get_code_info + get_code_package + not_supported does meta dump @@ -99,8 +102,6 @@ BEGIN { my ($coderef) = @_; ref($coderef) or return; - require B; - my $cv = B::svref_2object($coderef); $cv->isa('B::CV') or return; @@ -109,6 +110,18 @@ BEGIN { return ($gv->STASH->NAME, $gv->NAME); } + + sub get_code_package{ + my($coderef) = @_; + + my $cv = B::svref_2object($coderef); + $cv->isa('B::CV') or return ''; + + my $gv = $cv->GV; + $gv->isa('B::GV') or return ''; + + return $gv->STASH->NAME; + } } # taken from Mouse::Util (0.90) @@ -319,7 +332,7 @@ __END__ =head1 NAME -Mouse::Util - features, with or without their dependencies +Mouse::Util - Features, with or without their dependencies =head1 IMPLEMENTATIONS FOR @@ -337,7 +350,7 @@ Mouse::Util - features, with or without their dependencies =head2 Class::MOP -=head2 C<< is_class_loaded(ClassName) -> Bool >> +=head3 C<< is_class_loaded(ClassName) -> Bool >> Returns whether C is actually loaded or not. It uses a heuristic which involves checking for the existence of C<$VERSION>, C<@ISA>, and any @@ -359,13 +372,7 @@ C or using C. =head1 UTILITIES FOR MOUSE -=over 4 - -=item * - -C - -=back +=head3 C =head1 SEE ALSO