Commit | Line | Data |
692e1bcd |
1 | package Squirrel; |
692e1bcd |
2 | use strict; |
3 | use warnings; |
4 | |
5 | sub _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 | |
20 | my %pkgs; |
21 | |
22 | sub _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 | |
31 | sub 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 | |
37 | sub unimport { |
38 | goto $_[0]->_handlers->{unimport}; |
39 | } |
40 | |
a5053119 |
41 | 1; |
692e1bcd |
42 | |
43 | __END__ |
44 | |
45 | =pod |
46 | |
47 | =head1 NAME |
48 | |
49 | Squirrel - 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 | |
61 | L<Squirrel> is being deprecated. L<Any::Moose> provides the same functionality, |
62 | but better. :) |
63 | |
692e1bcd |
64 | =head1 DESCRIPTION |
65 | |
66 | L<Moose> and L<Squirrel> are TEH BEST FRENDS, but if L<Moose> isn't there |
103ad0e3 |
67 | L<Squirrel> will hang out with L<Mouse> as well. |
692e1bcd |
68 | |
69 | When your own code doesn't actually care whether or not you use L<Moose> or |
70 | L<Mouse> you can use either, and let your users decide for you. |
71 | |
72 | This lets you run with minimal dependencies and have a faster startup, but if |
d25ab495 |
73 | L<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 | |