8 our $AUTHORITY = 'cpan:STEVAN';
13 $package = $_[1] || 'Class';
14 if ($package =~ /^\+/) {
16 Class::MOP::load_class($package);
19 use Filter::Simple sub { s/^/package $package;\nuse Moose;use Moose::Util::TypeConstraints;\n/; }
24 # ABSTRACT: syntactic sugar to make Moose one-liners easier
32 # create a Moose class on the fly ...
33 perl -Moose=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
35 # loads an existing class (Moose or non-Moose)
36 # and re-"opens" the package definition to make
37 # debugging/introspection easier
38 perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
40 # also loads Moose::Util::TypeConstraints to allow subtypes etc
41 perl -Moose=Person -e'subtype q[ValidAge] => as q[Int] => where { $_ > 0 && $_ < 78 }; has => age ( isa => q[ValidAge], is => q[ro]); Person->new(age => 90)'
45 oose.pm is a simple source filter that adds C<package $name; use Moose;>
46 to the beginning of your script and was entirely created because typing
47 C<perl -e'package Foo; use Moose; ...'> was annoying me.
51 oose provides exactly one method and it's automatically called by perl:
55 =item B<import($package)>
57 Pass a package name to import to be used by the source filter.
63 You will need L<Filter::Simple> and eventually L<Moose>
65 =head1 INCOMPATIBILITIES
67 None reported. But it is a source filter and might have issues there.
71 See L<Moose/BUGS> for details on reporting bugs.