X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FSquirrel.pm;h=bbbad760cb3bfb37cdda36c22e9893cb7d1d8b7e;hp=6e2b856dc7fb9afc69e74214fd8e41d9beb96057;hb=e128626c409797822ffd8a4079f833eb3dc0fd37;hpb=692e1bcd8e516531416d8f6976f144080828b59e diff --git a/lib/Squirrel.pm b/lib/Squirrel.pm index 6e2b856..bbbad76 100644 --- a/lib/Squirrel.pm +++ b/lib/Squirrel.pm @@ -1,22 +1,21 @@ -#!/usr/bin/perl - package Squirrel; - use strict; use warnings; sub _choose_backend { if ( $INC{"Moose.pm"} ) { return { + backend => 'Moose', import => \&Moose::import, unimport => \&Moose::unimport, - } + }; } else { require Mouse; return { + backend => 'Mouse', import => \&Mouse::import, unimport => \&Mouse::unimport, - } + }; } } @@ -31,14 +30,21 @@ sub _handlers { } sub import { - goto $_[0]->_handlers->{import}; + require Carp; + Carp::carp("Squirrel is deprecated. Please use Any::Moose instead. It fixes a number of design problems that Squirrel has."); + + my $handlers = shift->_handlers; + unshift @_, $handlers->{backend}; + goto &{$handlers->{import}}; } sub unimport { - goto $_[0]->_handlers->{unimport}; + my $handlers = shift->_handlers; + unshift @_, $handlers->{backend}; + goto &{$handlers->{unimport}}; } -__PACKAGE__ +1; __END__ @@ -46,26 +52,36 @@ __END__ =head1 NAME -Squirrel - Use L, unless L is already loaded. +Squirrel - Use Mouse, unless Moose is already loaded. (DEPRECATED) =head1 SYNOPSIS - use Squirrel; + use Squirrel; has goggles => ( is => "rw", ); +=head1 DEPRECATION + +C is deprecated. C provides the same functionality, +but better. :) + =head1 DESCRIPTION -L and L are TEH BEST FRENDS, but if L isn't there -L will hang out with L as too. +L and L are THE BEST FRIENDS, but if L isn't there +L will hang out with L as well. When your own code doesn't actually care whether or not you use L or L you can use either, and let your users decide for you. This lets you run with minimal dependencies and have a faster startup, but if -L is already in use you get all the benefits of using that. +L is already in use you get all the benefits of using that +(transformability, introspection, more opportunities for code reuse, etc). + +=head1 SEE ALSO + +L =cut