Add a comment
[gitmo/Mouse.git] / lib / Squirrel.pm
CommitLineData
692e1bcd 1package Squirrel;
692e1bcd 2use strict;
3use warnings;
4
5sub _choose_backend {
6 if ( $INC{"Moose.pm"} ) {
7 return {
8 import => \&Moose::import,
9 unimport => \&Moose::unimport,
10 }
11 } else {
12 require Mouse;
13 return {
14 import => \&Mouse::import,
15 unimport => \&Mouse::unimport,
16 }
17 }
18}
19
20my %pkgs;
21
22sub _handlers {
23 my $class = shift;
24
25 my $caller = caller(1);
26
eb061d5b 27 $pkgs{$caller} = $class->_choose_backend
28 unless $pkgs{$caller};
692e1bcd 29}
30
31sub import {
2df74b3a 32 require Carp;
33 Carp::carp("Squirrel is deprecated. Please use Any::Moose instead. It fixes a number of design problems that Squirrel has.");
692e1bcd 34 goto $_[0]->_handlers->{import};
35}
36
37sub unimport {
38 goto $_[0]->_handlers->{unimport};
39}
40
a5053119 411;
692e1bcd 42
43__END__
44
45=pod
46
47=head1 NAME
48
49Squirrel - Use L<Mouse>, unless L<Moose> is already loaded.
50
51=head1 SYNOPSIS
52
53 use Squirrel;
54
55 has goggles => (
56 is => "rw",
57 );
58
a7387a2a 59=head1 DEPRECATION
60
61L<Squirrel> is being deprecated. L<Any::Moose> provides the same functionality,
62but better. :)
63
692e1bcd 64=head1 DESCRIPTION
65
66L<Moose> and L<Squirrel> are TEH BEST FRENDS, but if L<Moose> isn't there
103ad0e3 67L<Squirrel> will hang out with L<Mouse> as well.
692e1bcd 68
69When your own code doesn't actually care whether or not you use L<Moose> or
70L<Mouse> you can use either, and let your users decide for you.
71
72This lets you run with minimal dependencies and have a faster startup, but if
d25ab495 73L<Moose> is already in use you get all the benefits of using that
74(transformability, introspection, more opportunities for code reuse, etc).
692e1bcd 75
76=cut
77
78