Make does_role accept a role meta object
[gitmo/Mouse.git] / lib / ouse.pm
CommitLineData
b0e7066c 1package ouse;
2
b2317290 3use Mouse::Util; # enables strict and warnings
b0e7066c 4
b0e7066c 5BEGIN {
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
171;
b0e7066c 18__END__
19
b0e7066c 20=head1 NAME
21
22ouse - 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 36F<ouse.pm> is a simple source filter that adds C<package $name; use Mouse;>
b0e7066c 37to the beginning of your script and was entirely created because typing
1820fffe 38perl C<< -e'package Foo; use Mouse; ...' >> was annoying me... especially after
b0e7066c 39getting used to having C<-Moose> for Moose.
40
41=head1 INTERFACE
42
1820fffe 43C<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
49Pass a package name to import to be used by the source filter.
50
51=back
52
53=head1 DEPENDENCIES
54
55You will need L<Filter::Simple> and eventually L<Mouse>
56
57=head1 INCOMPATIBILITIES
58
59None reported. But it is a source filter and might have issues there.
60
1820fffe 61=head1 SEE ALSO
b0e7066c 62
1820fffe 63L<oose> for C<< perl -Moose -e '...' >>
b0e7066c 64
65=head1 AUTHOR
66
67For all intents and purposes, blame:
68
69Chris Prather C<< <perigrin@cpan.org> >>
70
6052a73a 71...who wrote oose.pm, which was adapted for use by Mouse by:
b0e7066c 72
73Ricardo SIGNES C<< <rjbs@cpan.org> >>
74
75=head1 COPYRIGHT AND LICENSE
76
77Copyright 2008 Shawn M Moore.
78
79This program is free software; you can redistribute it and/or modify it
80under the same terms as Perl itself.
81
82=cut