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