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