conflict on MooseX::SlurpyConstructor - latest is 1.2
[gitmo/Moose.git] / lib / oose.pm
CommitLineData
3eca5b1c 1package oose;
004222dc 2
3eca5b1c 3use strict;
25374f01 4use warnings;
5
0addec44 6use Class::MOP;
1321f087 7
3eca5b1c 8BEGIN {
9 my $package;
d03bd989 10 sub import {
1321f087 11 $package = $_[1] || 'Class';
12 if ($package =~ /^\+/) {
13 $package =~ s/^\+//;
14 Class::MOP::load_class($package);
15 }
16 }
405fb885 17 use Filter::Simple sub { s/^/package $package;\nuse Moose;use Moose::Util::TypeConstraints;\n/; }
3eca5b1c 18}
3eca5b1c 19
25374f01 201;
3eca5b1c 21
ad46f524 22# ABSTRACT: syntactic sugar to make Moose one-liners easier
23
25374f01 24__END__
3eca5b1c 25
25374f01 26=pod
3eca5b1c 27
3eca5b1c 28=head1 SYNOPSIS
29
1321f087 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
d03bd989 32
1321f087 33 # loads an existing class (Moose or non-Moose)
34 # and re-"opens" the package definition to make
35 # debugging/introspection easier
d03bd989 36 perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
3eca5b1c 37
405fb885 38 # also loads Moose::Util::TypeConstraints to allow subtypes etc
c3455158 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)'
405fb885 40
3eca5b1c 41=head1 DESCRIPTION
42
d03bd989 43oose.pm is a simple source filter that adds C<package $name; use Moose;>
44to the beginning of your script and was entirely created because typing
6549b0d1 45C<perl -e'package Foo; use Moose; ...'> was annoying me.
3eca5b1c 46
d03bd989 47=head1 INTERFACE
3eca5b1c 48
c7874946 49oose provides exactly one method and it's automatically called by perl:
1aa48307 50
25374f01 51=over 4
3eca5b1c 52
25374f01 53=item B<import($package)>
3eca5b1c 54
25374f01 55Pass a package name to import to be used by the source filter.
3eca5b1c 56
57=back
58
3eca5b1c 59=head1 DEPENDENCIES
60
3eca5b1c 61You will need L<Filter::Simple> and eventually L<Moose>
62
3eca5b1c 63=head1 INCOMPATIBILITIES
64
3eca5b1c 65None reported. But it is a source filter and might have issues there.
66
25374f01 67=head1 BUGS
3eca5b1c 68
d4048ef3 69See L<Moose/BUGS> for details on reporting bugs.
3eca5b1c 70
25374f01 71=cut