'Sub::Name' => '0.02',
'UNIVERSAL::require' => '0.10',
'Sub::Exporter' => '0.954',
- 'Sub::Install' => '0.92',
+ 'Sub::Install' => '0.92',
+ 'B' => '0',
},
optional => {
},
Revision history for Perl extension Moose
+0.11
+ * Moose
+ - added an &unimport method to remove all the keywords
+ that Moose will import
+
+ * t/
+ - fixed some test failures caused by a forgotten test
+ dependency.
+
0.10 Thurs. July 6, 2006
* Moose
- improved error message when loading modules so
t/015_override_and_foreign_classes.t
t/016_always_strict_warnings.t
t/017_wrapped_method_context_propagation.t
+t/018_import_unimport.t
t/020_foreign_inheritence.t
t/021_moose_w_metaclass.t
t/022_moose_respects_base.t
-Moose version 0.10
+Moose version 0.11
===========================
See the individual module documentation for more information
Sub::Name
UNIVERSAL::require
Sub::Exporter
+ B
COPYRIGHT AND LICENCE
use strict;
use warnings;
-our $VERSION = '0.10';
+our $VERSION = '0.11';
use Scalar::Util 'blessed', 'reftype';
use Carp 'confess';
use Sub::Name 'subname';
+use B 'svref_2object';
use UNIVERSAL::require;
use Sub::Exporter;
goto $exporter;
}
+
+ sub unimport {
+ no strict 'refs';
+ my $class = 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
+ my $pkg_name = eval { svref_2object($keyword)->GV->STASH->NAME };
+ next if $@;
+ next if $pkg_name ne 'Moose';
+
+ # and if it is from Moose then undef the slot
+ delete ${$class . '::'}{$name};
+ }
+ }
+ }
}
## Utility functions
=head1 NAME
-Moose - Moose, it's the new Camel
+Moose - A complete modern object system for Perl 5
=head1 SYNOPSIS
=back
+=head1 UNEXPORTING FUNCTIONS
+
+=head2 B<unimport>
+
+Moose offers a way of removing the keywords it exports though the C<unimport>
+method. You simply have to say C<no Moose> at the bottom of your code for this
+to work. Here is an example:
+
+ package Person;
+ use Moose;
+
+ has 'first_name' => (is => 'rw', isa => 'Str');
+ has 'last_name' => (is => 'rw', isa => 'Str');
+
+ sub full_name {
+ my $self = shift;
+ $self->first_name . ' ' . $self->last_name
+ }
+
+ no Moose; # keywords are removed from the Person package
+
=head1 FUTURE PLANS
Here is just a sampling of the plans we have in store for Moose:
BEGIN {
use_ok('Moose');
-}
\ No newline at end of file
+}
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 23;
+
+BEGIN {
+ use_ok('Moose');
+}
+
+my @moose_exports = qw(
+ extends with
+ has
+ before after around
+ override super
+ augment inner
+);
+
+{
+ package Foo;
+}
+
+eval q{
+ package Foo;
+ use Moose;
+};
+ok(!$@, '... Moose succesfully exported into Foo');
+
+can_ok('Foo', $_) for @moose_exports;
+
+eval q{
+ package Foo;
+ no Moose;
+};
+ok(!$@, '... Moose succesfully un-exported from Foo');
+
+ok(!Foo->can($_), '... Foo can no longer do ' . $_) for @moose_exports;
\ No newline at end of file
use Test::More;
BEGIN {
- eval "use DBM::Deep;";
- plan skip_all => "DBM::Deep required for this test" if $@;
+ eval "use DBM::Deep 0.983; use DateTime::Format::MySQL;";
+ plan skip_all => "DBM::Deep and DateTime::Format::MySQL required for this test" if $@;
plan tests => 89;
}