X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fouse.pm;h=aac678122e2585455a5cd76ad387a80b5db7991a;hb=983d58a5ea543a21c48cb04311883f1b36de1874;hp=6ebf64dc5a60e9a1dd198d3a5bede68891b69093;hpb=cf59b7151d2b476a74b5abd84af37770ad4cf387;p=gitmo%2FMouse.git diff --git a/lib/ouse.pm b/lib/ouse.pm index 6ebf64dc..aac6781 100644 --- a/lib/ouse.pm +++ b/lib/ouse.pm @@ -1,19 +1,15 @@ package ouse; - -use strict; -use warnings; - -BEGIN { - my $package; - sub import { - $package = $_[1] || 'Class'; - if ($package =~ /^\+/) { - $package =~ s/^\+//; - eval "require $package; 1" or die; - } +use Mouse::Util; # enables strict and warnings + +my $package = 'Class'; +sub import { + $package = $_[1] || 'Class'; + if ($package =~ /^\+/) { + $package =~ s/^\+//; + Mouse::Util::load_class($package); } - use Filter::Simple sub { s/^/package $package;\nuse Mouse;\n/; } } +use Filter::Simple sub { s/^/package $package;\nuse Mouse;\nuse Mouse::Util::TypeConstraints;\n/; }; 1; __END__ @@ -30,16 +26,16 @@ ouse - syntactic sugar to make Mouse one-liners easier # loads an existing class (Mouse or non-Mouse) # and re-"opens" the package definition to make # debugging/introspection easier - perl -Mouse=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list' + perl -Mouse=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list' =head1 DESCRIPTION -F is a simple source filter that adds C -to the beginning of your script and was entirely created because typing +F is a simple source filter that adds C +to the beginning of your script and was entirely created because typing perl C<< -e'package Foo; use Mouse; ...' >> was annoying me... especially after getting used to having C<-Moose> for Moose. -=head1 INTERFACE +=head1 INTERFACE C provides exactly one method and it is automatically called by perl: