Aion-Enum
view release on metacpan or search on metacpan
lib/Aion/Enum.pm view on Meta::CPAN
require StringEnum # @-> active alias must have the type StrMatch[qr/^[A-Z]/]. The it is 'pushkin'!
=head1 CLASS METHODS
=head2 cases ($cls)
List of transfers.
[ OrderEnum->cases ] # --> [OrderEnum->first, OrderEnum->second, OrderEnum->other]
=head2 names ($cls)
Names of transfers.
[ OrderEnum->names ] # --> [qw/first second other/]
=head2 values ($cls)
The values of the transfers.
[ OrderEnum->values ] # --> [undef, 2, 3]
=head2 stashes ($cls)
Additions of transfers.
[ OrderEnum->stashes ] # --> [undef, undef, {data => 123}]
=head2 aliases ($cls)
Pseudonyms of transfers.
LIB/authorenum.pm file:
package AuthorEnum;
use Aion::Enum;
# Pushkin Aleksandr Sergeevich
case pushkin =>;
# Yacheykin Uriy
case yacheykin =>;
case nouname =>;
1;
require AuthorEnum;
[ AuthorEnum->aliases ] # --> ['Pushkin Aleksandr Sergeevich', 'Yacheykin Uriy', undef]
=head2 fromName ($cls, $name)
Get Case by name with exceptions.
OrderEnum->fromName('first') # -> OrderEnum->first
eval { OrderEnum->fromName('not_exists') }; $@ # ~> Did not case with name `not_exists`!
=head2 tryFromName ($cls, $name)
Get Case by name.
OrderEnum->tryFromName('first') # -> OrderEnum->first
OrderEnum->tryFromName('not_exists') # -> undef
=head2 fromValue ($cls, $value)
Get Case by value with exceptions.
OrderEnum->fromValue(undef) # -> OrderEnum->first
eval { OrderEnum->fromValue('not-exists') }; $@ # ~> Did not case with value `not-exists`!
=head2 tryFromValue ($cls, $value)
Get Case by value.
OrderEnum->tryFromValue(undef) # -> OrderEnum->first
OrderEnum->tryFromValue('not-exists') # -> undef
=head2 fromStash ($cls, $stash)
Get CASE on addition with exceptions.
OrderEnum->fromStash(undef) # -> OrderEnum->first
eval { OrderEnum->fromStash('not-exists') }; $@ # ~> Did not case with stash `not-exists`!
=head2 tryFromStash ($cls, $value)
Get Case for addition.
OrderEnum->tryFromStash({data => 123}) # -> OrderEnum->other
OrderEnum->tryFromStash('not-exists') # -> undef
=head2 fromAlias ($cls, $alias)
Get Case by pseudonym with exceptions.
AuthorEnum->fromAlias('Yacheykin Uriy') # -> AuthorEnum->yacheykin
eval { AuthorEnum->fromAlias('not-exists') }; $@ # ~> Did not case with alias `not-exists`!
=head2 tryFromAlias ($cls, $alias)
Get case by alias.
AuthorEnum->tryFromAlias('Yacheykin Uriy') # -> AuthorEnum->yacheykin
AuthorEnum->tryFromAlias('not-exists') # -> undef
=head1 FEATURES
=head2 name
Property only for reading.
package NameEnum {
use Aion::Enum;
case piter =>;
}
NameEnum->piter->name # => piter
=head2 value
Property only for reading.
( run in 1.220 second using v1.01-cache-2.11-cpan-9581c071862 )