Implement strict constructors, which will warn unkown constructor arguments
[gitmo/Mouse.git] / lib / ouse.pm
1 package ouse;
2
3 use Mouse::Util; # enables strict and warnings
4
5 BEGIN {
6     my $package;
7     sub import { 
8         $package = $_[1] || 'Class';
9         if ($package =~ /^\+/) {
10             $package =~ s/^\+//;
11             Mouse::Util::load_class($package);
12         }
13     }
14     use Filter::Simple sub { s/^/package $package;\nuse Mouse;\nuse Mouse::Util::TypeConstraints;\n/; }
15 }
16
17 1;
18 __END__
19
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
36 F<ouse.pm> is a simple source filter that adds C<package $name; use Mouse;> 
37 to the beginning of your script and was entirely created because typing 
38 perl C<< -e'package Foo; use Mouse; ...' >> was annoying me... especially after
39 getting used to having C<-Moose> for Moose.
40
41 =head1 INTERFACE 
42
43 C<ouse> provides exactly one method and it is automatically called by perl:
44
45 =over 4
46
47 =item C<< oose->import() >>>
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
61 =head1 SEE ALSO
62
63 L<oose> for C<< perl -Moose -e '...' >>
64
65 =head1 AUTHOR
66
67 For all intents and purposes, blame:
68
69 Chris Prather  C<< <perigrin@cpan.org> >>
70
71 ...who wrote oose.pm, which was adapted for use by Mouse by:
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