use Data::OptList;
use Sub::Exporter;
-our $VERSION = '0.09';
+our $VERSION = '0.55';
our $AUTHORITY = 'cpan:STEVAN';
use Moose ();
extends => sub {
my $meta = _find_meta();
return Class::MOP::subname('Moose::Role::extends' => sub {
- croak "Moose::Role does not currently support 'extends'"
+ croak "Roles do not currently support 'extends'"
});
},
with => sub {
goto $exporter;
};
+ sub unimport {
+ no strict 'refs';
+ my $class = Moose::_get_caller(@_);
+
+ # loop through the exports ...
+ foreach my $name ( keys %exports ) {
+
+ # if we find one ...
+ if ( defined &{ $class . '::' . $name } ) {
+ my $keyword = \&{ $class . '::' . $name };
+
+ # make sure it is from Moose::Role
+ my ($pkg_name) = Class::MOP::get_code_info($keyword);
+ next if $pkg_name ne 'Moose::Role';
+
+ # and if it is from Moose::Role then undef the slot
+ delete ${ $class . '::' }{$name};
+ }
+ }
+ }
}
1;
=back
+=head2 B<unimport>
+
+Moose::Role offers a way to remove the keywords it exports, through the
+C<unimport> method. You simply have to say C<no Moose::Role> at the bottom of
+your code for this to work.
+
=head1 CAVEATS
Role support has only a few caveats: