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