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