Revision history for Perl extension Moose
+0.51
+ * Moose::Role
+ - add unimport so "no Moose::Role" actually does something
+
0.50 Thurs. Jun 11, 2008
- Fixed a version number issue by bumping all modules
to 0.50.
goto $exporter;
};
+ sub unimport {
+ no strict 'refs';
+ my $class = _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: