1
In object oriented abstractions you often model real things as Perl classes.
2
Unfortunately, the Perl classes have uglier names than the real things do.
4
For example, I might model a customer using a Foo::Customer class.
6
It would be useful if the Foo::Customer class knew what I would call its
9
UNIVERSAL::moniker enables classes to make a good guess at what they would be
10
called in the real world.
12
Foo::User->moniker eq "user";
14
my $a = Big::Scary::Animal->new;
15
$c->moniker eq "animal";
17
my $o = Cephalopod::Octopus->new;
18
$o->plural_moniker eq "octopuses";
20
==============================================================================
26
use UNIVERSAL::moniker;
29
Class names in Perl often don't sound great when spoken, or look good
30
when written in prose. For this reason, we tend to say things like
31
"customer" or "basket" when we are referring to
32
"My::Site::User::Customer" or "My::Site::Shop::Basket". We thought it
33
would be nice if our classes knew what we would prefer to call them.
35
This module will add a "moniker" (and "plural_moniker") method to
36
"UNIVERSAL", and so to every class or module.
41
Returns the moniker for $ob. So, if $ob->isa("Big::Scary::Animal"),
42
"moniker" will return "animal".
47
Returns the plural moniker for $ob. So, if
48
$ob->isa("Cephalopod::Octopus"), "plural_moniker" will return
51
(You need to install Lingua::EN::Inflect for this to work.)
54
Marty Pauley <marty+perl@kasei.com>, Tony Bowden <tony@kasei.com>,
55
Elizabeth Mattijsen <liz@dijkmat.nl>
57
(Yes, 3 authors for such a small module!)
60
Copyright (C) 2004 Kasei
62
This program is free software; you can redistribute it under the same terms as
65
This program is distributed in the hope that it will be useful, but WITHOUT
66
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
67
FOR A PARTICULAR PURPOSE.