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