make_immutable is now deprecated, stop using it and a fix your old code please
[gitmo/Moose.git] / lib / oose.pm
CommitLineData
3eca5b1c 1package oose;
2use strict;
25374f01 3use warnings;
4
1321f087 5use Class::MOP;
6
7our $VERSION = '0.03';
25374f01 8our $AUTHORITY = 'cpan:STEVAN';
3eca5b1c 9
10BEGIN {
11 my $package;
1321f087 12 sub import {
13 $package = $_[1] || 'Class';
14 if ($package =~ /^\+/) {
15 $package =~ s/^\+//;
16 Class::MOP::load_class($package);
17 }
18 }
3eca5b1c 19 use Filter::Simple sub { s/^/package $package;\nuse Moose;\n/; }
20}
3eca5b1c 21
25374f01 221;
3eca5b1c 23
25374f01 24__END__
3eca5b1c 25
25374f01 26=pod
3eca5b1c 27
25374f01 28=head1 NAME
3eca5b1c 29
25374f01 30oose - syntactic sugar to make Moose one-liners easier
3eca5b1c 31
32=head1 SYNOPSIS
33
1321f087 34 # create a Moose class on the fly ...
35 perl -Moose=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
36
37 # loads an existing class (Moose or non-Moose)
38 # and re-"opens" the package definition to make
39 # debugging/introspection easier
40 perl -Moose=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
3eca5b1c 41
42=head1 DESCRIPTION
43
25374f01 44oose.pm is a simple source filter that adds C<package $name; use Moose;>
45to the beginning of your script and was entirely created because typing
46perl -e'package Foo; use Moose; ...' was annoying me.
3eca5b1c 47
48=head1 INTERFACE
49
50oose provides exactly one method and it's automically called by perl:
1aa48307 51
25374f01 52=over 4
3eca5b1c 53
25374f01 54=item B<import($package)>
3eca5b1c 55
25374f01 56Pass a package name to import to be used by the source filter.
3eca5b1c 57
58=back
59
3eca5b1c 60=head1 DEPENDENCIES
61
3eca5b1c 62You will need L<Filter::Simple> and eventually L<Moose>
63
3eca5b1c 64=head1 INCOMPATIBILITIES
65
3eca5b1c 66None reported. But it is a source filter and might have issues there.
67
25374f01 68=head1 BUGS
3eca5b1c 69
25374f01 70All complex software has bugs lurking in it, and this module is no
71exception. If you find a bug please either email me, or add the bug
72to cpan-RT.
3eca5b1c 73
74=head1 AUTHOR
75
76Chris Prather C<< <perigrin@cpan.org> >>
77
25374f01 78=head1 COPYRIGHT AND LICENSE
3eca5b1c 79
778db3ac 80Copyright 2007-2008 by Infinity Interactive, Inc.
3eca5b1c 81
25374f01 82L<http://www.iinteractive.com>
3eca5b1c 83
25374f01 84This library is free software; you can redistribute it and/or modify
85it under the same terms as Perl itself.
3eca5b1c 86
25374f01 87=cut