6 use Class::Load qw(load_class);
11 $package = $_[1] || 'Class';
12 if ($package =~ /^\+/) {
17 use Filter::Simple sub { s/^/package $package;\nuse Moose;use Moose::Util::TypeConstraints;\n/; }
22 # ABSTRACT: syntactic sugar to make Moose one-liners easier
30 # create a Moose class on the fly ...
31 perl -Moose=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
33 # loads an existing class (Moose or non-Moose)
34 # and re-"opens" the package definition to make
35 # debugging/introspection easier
36 perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
38 # also loads Moose::Util::TypeConstraints to allow subtypes etc
39 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)'
43 oose.pm is a simple source filter that adds
44 C<package $name; use Moose; use Moose::Util::TypeConstraints;>
45 to the beginning of your script and was entirely created because typing
46 C<perl -e'package Foo; use Moose; ...'> was annoying me.
50 oose provides exactly one method and it's automatically called by perl:
54 =item B<import($package)>
56 Pass a package name to import to be used by the source filter. The
57 package defaults to C<Class> if none is given.
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.