-
-
05 Jan 2016 14:47:53 UTC
- Distribution: Class-Enumemon
- Module version: 0.01
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (2)
- Testers (522 / 0 / 0)
- Kwalitee
Bus factor: 0- 99.16% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (10.88KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Carp
- Guard
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Class::Enumemon - enum-like class generator
SYNOPSIS
package IdolType; use Class::Enumemon ( values => 1, getter => 1, indexer => { by_id => 'id', from_type => 'type', }, { id => 1, type => 'cute', }, { id => 2, type => 'cool', }, { id => 3, type => 'passion', }, ); 1; package My::Pkg; use IdolType; # `values`: defines a method for getting all values IdolType->values; #=> [ bless({ id => 1, type => 'cute' }, 'IdolType'), ... ] # `indexer`: defines indexer methods to package my $cu = IdolType->by_id(1); #=> bless({ id => 1, type => 'cute' }, 'IdolType') IdonType->from_type('cool'); #=> bless({ id => 2, type => 'cool' }, 'IdolType') IdonType->values->[2]; #=> bless({ id => 3, type => 'passion' }, 'IdolType') # `getter`: defines getter methods to instance $cu->id; #=> 1 $cu->type; #=> 'cute' # `local`: makes a guard object for overriding its data lexically { my $guard = IdolType->local( { id => 1, type => 'vocal', }, { id => 2, type => 'dance', }, { id => 3, type => 'visual', }, ); IdolType->by_id(1) #=> bless({ id => 1, type => 'vocal' }, 'IdolType') IdolType->from_type('dance') #=> bless({ id => 1, type => 'dance' }, 'IdolType') IdolType->from_type('cute') #=> undef } IdolType->from_type('cute') #=> bless({ id => 1, type => 'cute' }, 'IdolType')
DESCRIPTION
Class::Enumemon generate enum-like classes with typical methods that are getter for all, indexer, accessor and guard generator. An instance fetched from package is always same reference with another.
LICENSE
Copyright (C) pokutuna.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHORS
pokutuna (POKUDA Tunahiko) <popopopopokutuna@gmail.com>
nanto_vi (TOYAMA Nao) <nanto@moon.email.ne.jp>
mechairoi (TSUJIKAWA Takaya) <ttsujikawa@gmail.com>
SEE ALSO
Module Install Instructions
To install Class::Enumemon, copy and paste the appropriate command in to your terminal.
cpanm Class::Enumemon
perl -MCPAN -e shell install Class::Enumemon
For more information on module installation, please visit the detailed CPAN module installation guide.