do not use same variable name twice.
[gitmo/Mouse.git] / lib / ouse.pm
CommitLineData
b0e7066c 1package ouse;
2
3use strict;
4use warnings;
5
b0e7066c 6BEGIN {
7 my $package;
8 sub import {
9 $package = $_[1] || 'Class';
10 if ($package =~ /^\+/) {
11 $package =~ s/^\+//;
12 eval "require $package; 1" or die;
13 }
14 }
15 use Filter::Simple sub { s/^/package $package;\nuse Mouse;\n/; }
16}
17
181;
19
20__END__
21
22=pod
23
24=head1 NAME
25
26ouse - syntactic sugar to make Mouse one-liners easier
27
28=head1 SYNOPSIS
29
30 # create a Mouse class on the fly ...
31 perl -Mouse=Foo -e 'has bar => ( is=>q[ro], default => q[baz] ); print Foo->new->bar' # prints baz
32
33 # loads an existing class (Mouse or non-Mouse)
34 # and re-"opens" the package definition to make
35 # debugging/introspection easier
36 perl -Mouse=+My::Class -e 'print join ", " => __PACKAGE__->meta->get_method_list'
37
38=head1 DESCRIPTION
39
40ouse.pm is a simple source filter that adds C<package $name; use Mouse;>
41to the beginning of your script and was entirely created because typing
42perl -e'package Foo; use Mouse; ...' was annoying me... especially after
43getting used to having C<-Moose> for Moose.
44
45=head1 INTERFACE
46
47ouse provides exactly one method and it's automically called by perl:
48
49=over 4
50
51=item B<import($package)>
52
53Pass a package name to import to be used by the source filter.
54
55=back
56
57=head1 DEPENDENCIES
58
59You will need L<Filter::Simple> and eventually L<Mouse>
60
61=head1 INCOMPATIBILITIES
62
63None reported. But it is a source filter and might have issues there.
64
65=head1 BUGS
66
67All complex software has bugs lurking in it, and this module is no
68exception. If you find a bug please either email me, or add the bug
69to cpan-RT.
70
71=head1 AUTHOR
72
73For all intents and purposes, blame:
74
75Chris Prather C<< <perigrin@cpan.org> >>
76
77...who wrote ouse.pm, which was adapted for use by Mouse by:
78
79Ricardo SIGNES C<< <rjbs@cpan.org> >>
80
81=head1 COPYRIGHT AND LICENSE
82
83Copyright 2008 Shawn M Moore.
84
85This program is free software; you can redistribute it and/or modify it
86under the same terms as Perl itself.
87
88=cut