Skip to content

Commit

Permalink
Fixed typo in doc, added NonMooX feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed May 7, 2012
1 parent e6b01c2 commit afc62ff
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
16 changes: 12 additions & 4 deletions lib/MooX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ sub import {
unshift @modules, 'Moo';
while (@modules) {
my $package = shift @modules;
$package = 'MooX::'.$package unless $package eq 'Moo';
if (substr($package,0,1) eq '+') {
$package = substr($package,1);
} elsif ($package eq 'Moo') {
# do nothing
} else {
$package = 'MooX::'.$package;
}
croak "No package name given" if ref $package;
my @args = ref $modules[0] eq 'ARRAY'
? @{shift @modules}
Expand Down Expand Up @@ -43,12 +49,14 @@ sub import {
use MooX
SomeThing => [qw( import params )],
OtherThing, MoreThing => { key => 'value' };
'OtherThing', MoreThing => { key => 'value' },
'+NonMooXStuff';
# use Moo;
# use MooX::SomeThing qw( import params );
# use OtherThing;
# use MoreThing key => 'value';
# use MooX::OtherThing;
# use MooX::MoreThing key => 'value';
# use NonMooXStuff;
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion t/02-importparams.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ eval "use MooXTestTest;";

my $mooxtesttest = MooXTestTest->new;

is($COUNT,6,'Correct import function called with proper parameters');
is($COUNT,60,'Correct import function called with proper parameters');
isa_ok($mooxtesttest,'Moo::Object');

done_testing;
20 changes: 20 additions & 0 deletions t/03-nonmoox.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/perl
package main;

use strict;
use warnings;
use Test::More;

use FindBin qw($Bin);
use lib "$Bin/lib";

our $COUNT = 0;

eval "use MooXTestTestTest;";

my $mooxtesttesttest = MooXTestTestTest->new;

is($COUNT,101,'Correct import function called on NonMooX class');
isa_ok($mooxtesttesttest,'Moo::Object');

done_testing;
2 changes: 1 addition & 1 deletion t/lib/MooXTestTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package MooXTestTest;
use strict;
use warnings;

use MooX D => [qw( 1 2 3 )];
use MooX D => [qw( 10 20 30 )];

1;
8 changes: 8 additions & 0 deletions t/lib/MooXTestTestTest.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package MooXTestTestTest;

use strict;
use warnings;

use MooX 'A', '+NonMooX::A';

1;
10 changes: 10 additions & 0 deletions t/lib/NonMooX/A.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package NonMooX::A;

use strict;
use warnings;

sub import {
$main::COUNT += 100 if $main::COUNT == 1;
}

1;

0 comments on commit afc62ff

Please sign in to comment.