1package UNIVERSAL::moniker; 2$UNIVERSAL::moniker::VERSION = '0.08'; 3 4=head1 NAME 5 6UNIVERSAL::moniker 7 8=head1 SYNOPSIS 9 10 use UNIVERSAL::moniker; 11 12=head1 DESCRIPTION 13 14Class names in Perl often don't sound great when spoken, or look good when 15written 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 17C<My::Site::Shop::Basket>. We thought it would be nice if our classes knew what 18we would prefer to call them. 19 20This module will add a C<moniker> (and C<plural_moniker>) method to 21C<UNIVERSAL>, and so to every class or module. 22 23=head2 moniker 24 25 $ob->moniker; 26 27Returns the moniker for $ob. 28So, if $ob->isa("Big::Scary::Animal"), C<moniker> will return "animal". 29 30=head2 plural_moniker 31 32 $ob->plural_moniker; 33 34Returns the plural moniker for $ob. 35So, 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 41package UNIVERSAL; 42 43sub moniker { 44 (ref( $_[0] ) || $_[0]) =~ /([^:]+)$/; 45 return lc $1; 46} 47 48sub plural_moniker { 49 CORE::require Lingua::EN::Inflect; 50 return Lingua::EN::Inflect::PL($_[0]->moniker); 51} 52 53=head1 AUTHORS 54 55Marty Pauley <marty+perl@kasei.com>, 56Tony Bowden <tony@kasei.com>, 57Elizabeth 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 751; 76