X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fouse.pm;h=aac678122e2585455a5cd76ad387a80b5db7991a;hb=7f881031a63a80846be81c6f06e7285095582782;hp=3026ced6f64e1161d3e524b6207dea1030453d3e;hpb=1820fffecb0bd1da64edc16ecde534178b841d14;p=gitmo%2FMouse.git diff --git a/lib/ouse.pm b/lib/ouse.pm index 3026ced..aac6781 100644 --- a/lib/ouse.pm +++ b/lib/ouse.pm @@ -1,26 +1,19 @@ 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__ -=pod - =head1 NAME ouse - syntactic sugar to make Mouse one-liners easier @@ -33,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: