package Mouse::Util;
use strict;
use warnings;
-use base qw/Exporter/;
+
+use Exporter;
use Carp qw(confess);
use B ();
+use constant _MOUSE_VERBOSE => !!$ENV{MOUSE_VERBOSE};
+
+our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
find_meta
does_role
get_linear_isa
get_code_info
+ get_code_package
+
not_supported
does meta dump
+ _MOUSE_VERBOSE
);
our %EXPORT_TAGS = (
all => \@EXPORT_OK,
- meta => [qw(does meta dump)],
+ meta => [qw(does meta dump _MOUSE_VERBOSE)],
);
# Moose::Util compatible utilities
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)
if ($i + 1 < $max && ref($_[$i + 1])) {
push @roles, [ $_[$i++] => $_[$i] ];
} else {
- push @roles, [ $_[$i] => {} ];
+ push @roles, [ $_[$i] => undef ];
}
my $role_name = $roles[-1][0];
load_class($role_name);
=head1 NAME
-Mouse::Util - features, with or without their dependencies
+Mouse::Util - Features, with or without their dependencies
=head1 IMPLEMENTATIONS FOR
=head2 Class::MOP
-=head3 C<is_class_loaded>
+=head3 C<< is_class_loaded(ClassName) -> Bool >>
+
+Returns whether C<ClassName> is actually loaded or not. It uses a heuristic which
+involves checking for the existence of C<$VERSION>, C<@ISA>, and any
+locally-defined method.
-=head3 C<load_class>
+=head3 C<< load_class(ClassName) >>
+
+This will load a given C<ClassName> (or die if it's not loadable).
+This function can be used in place of tricks like
+C<eval "use $module"> or using C<require>.
=head2 MRO::Compat
=head1 UTILITIES FOR MOUSE
-=over 4
+=head3 C<not_supported>
+
+=head1 SEE ALSO
+
+L<Moose::Util>
-=item *
+L<Scalar::Util>
-C<not_supported>
+L<Sub::Identify>
-=back
+L<MRO::Compat>
=cut