1.0003 5 Mar 2008
Fix tests on perl 5.10.0
-1.0002 4 Mar 2008
+1.0002 4 Mar 2008
Make tests more resilient
1.0001 11 Aug 2007
package main;
- MyModule->load_components( qw/Foo Bar/ );
+ MyModule->load_components( qw/Foo Bar/ );
# Will load MyModule::Component::Foo and MyModule::Component::Bar
=head1 DESCRIPTION
This will inject base classes to your module using the L<Class::C3> method
resolution order.
-Please note: these are not plugins that can take precedence over methods
+Please note: these are not plugins that can take precedence over methods
declared in MyModule. If you want something like that, consider
L<MooseX::Object::Pluggable>.
=head2 load_components( @comps )
-Loads the given components into the current module. If a module begins with a
+Loads the given components into the current module. If a module begins with a
C<+> character, it is taken to be a fully qualified class name, otherwise
C<< $class->component_base_class >> is prepended to it.
=head2 load_optional_components
-As L<load_components>, but will silently ignore any components that cannot be
+As L<load_components>, but will silently ignore any components that cannot be
found.
=cut
$target->$f($parent)
}
}
-}
+}
{
no strict 'refs';
=head1 DESCRIPTION
This package allows a given component to run methods on the class that is being
-injected into before or after the component is injected. Note from the
+injected into before or after the component is injected. Note from the
L</SYNOPSIS> that all C<Load Actions> may be run more than once.
=head1 IMPORT ACTION
use Test::More tests => 1;
BEGIN {
- use_ok( 'Class::C3::Componentised' );
+ use_ok( 'Class::C3::Componentised' );
}
diag( "Testing Class::C3::Componentised $Class::C3::Componentised::VERSION, Perl $], $^X" );
like( $@, qr/Invalid class name 'ENDS::WITH::COLONS::'/, 'Throw on Class::' );
# Simulate a PAR environment
-{
+{
my @code;
local @INC = @INC;
unshift @INC, sub {
$retval = eval { MyModule->load_optional_class('FAKE::PAR::PACKAGE') };
ok( !$@, 'load_optional_class on a nonexistent PAR class did not throw' );
ok( !$retval, 'nonexistent PAR package not loaded' );
-
+
# simulate a class which does load but does not return true
@code = (
$retval = eval { MyModule->load_optional_class('VIRTUAL::PAR::PACKAGE') };
ok( $@, 'load_optional_class of a no-true-returning PAR module did throw' );
ok( !$retval, 'no-true-returning PAR package not loaded' );
-
+
# simulate a normal class (no one adjusted %INC so it will be tried again
@code = (
q/package VIRTUAL::PAR::PACKAGE;/,
$retval = eval { MyModule->load_optional_class('VIRTUAL::PAR::PACKAGE') };
ok( !$@, 'load_optional_class of a PAR module did not throw' );
ok( $retval, 'PAR package "loaded"' );
-
+
# see if we can still load stuff with the coderef present
$retval = eval { MyModule->load_optional_class('AnotherModule') };
ok( !$@, 'load_optional_class did not throw' ) || diag $@;
sub component_base_class { "MyModule::Plugin" }
-sub message {
+sub message {
my $msg = $_[0]->maybe::next::method() || '';
-
+
return $msg . ' ' . __PACKAGE__;
}
-sub new {
+sub new {
return bless {}, shift;
}
use MRO::Compat;
use mro 'c3';
-sub message {
+sub message {
"Foo";
}
use base 'Class::C3::Componentised';
-sub message {
+sub message {
my $msg = $_[0]->maybe::next::method() || '';
-
+
return $msg . ' ' . __PACKAGE__;
}
-sub new {
+sub new {
return bless {}, shift;
}