home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / moniker.pm < prev    next >
Encoding:
Perl POD Document  |  2004-02-24  |  1.7 KB  |  76 lines

  1. package UNIVERSAL::moniker;
  2. $UNIVERSAL::moniker::VERSION = '0.07';
  3.  
  4. =head1 NAME
  5.  
  6. UNIVERSAL::moniker
  7.  
  8. =head1 SYNOPSIS
  9.  
  10.   use UNIVERSAL::moniker;
  11.  
  12. =head1 DESCRIPTION
  13.  
  14. Class names in Perl often don't sound great when spoken, or look good when
  15. written in prose.  For this reason, we tend to say things like "customer" or
  16. "basket" when we are referring to C<My::Site::User::Customer> or
  17. C<My::Site::Shop::Basket>.  We thought it would be nice if our classes knew what
  18. we would prefer to call them.
  19.  
  20. This module will add a C<moniker> (and C<plural_moniker>) method to
  21. C<UNIVERSAL>, and so to every class or module.
  22.  
  23. =head2 moniker
  24.  
  25.   $ob->moniker;
  26.  
  27. Returns the moniker for $ob.
  28. So, if $ob->isa("Big::Scary::Animal"), C<moniker> will return "animal".
  29.  
  30. =head2 plural_moniker
  31.  
  32.   $ob->plural_moniker;
  33.  
  34. Returns the plural moniker for $ob.
  35. So, if $ob->isa("Cephalopod::Octopus"), C<plural_moniker> will return "octopuses".
  36.  
  37. (You need to install Lingua::EN::Inflect for this to work.)
  38.  
  39. =cut
  40.  
  41. package UNIVERSAL;
  42.  
  43. sub moniker {
  44.     (ref( $_[0] ) || $_[0]) =~ /([^:]+)$/;
  45.     return lc $1;
  46. }
  47.  
  48. sub plural_moniker {
  49.     require Lingua::EN::Inflect;
  50.     return Lingua::EN::Inflect::PL($_[0]->moniker);
  51. }
  52.  
  53. =head1 AUTHORS
  54.  
  55. Marty Pauley <marty+perl@kasei.com>,
  56. Tony Bowden <tony@kasei.com>,
  57. Elizabeth Mattijsen <liz@dijkmat.nl>
  58.  
  59. (Yes, 3 authors for such a small module!)
  60.  
  61. =head1 COPYRIGHT
  62.  
  63.   Copyright (C) 2004 Kasei
  64.  
  65.   This program is free software; you can redistribute it under the same terms as
  66.   Perl.
  67.  
  68.   This program is distributed in the hope that it will be useful, but WITHOUT
  69.   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  70.   FOR A PARTICULAR PURPOSE.
  71.  
  72. =cut
  73.  
  74.  
  75. 1;
  76.