home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / perl5 / Squirrel.pm < prev    next >
Encoding:
Perl POD Document  |  2009-10-09  |  1.8 KB  |  89 lines

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