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