YATT::Lite::Types - define inner types at compile time.
In module MyClass.pm:
package MyClass; use YATT::Lite::Types (base => 'MyBaseClass' , [Album => fields => [qw/albumid artist title/]] , [CD => fields => [qw/cdid artist title/]] , [Track => fields => [qw/trackid cd title/]] ); # Now you have MyClass::Album, MyClass::CD and MyClass::Track. # also, alias (constant sub) of them are defined. my Album $album = Album->new; # my Albumm $album; # => No such class Albumm my CD $cd = CD->new; # $cd->{artistt}; # => No such class field "artistt" in variable $cd of type MyClass::CD my Track $track = {}; $track->{cd} = $cd; # $track->{cdd} = $cd; # => No such class field "cdd" in variable $track of type MyClass::Track 1;
YATT::Lite::Types is a class builder, especially suitable to defining many inner classes at once.
Basic usage is like this:
use YATT::Lite::Types (OPTION => VALUE, ... , [SPEC] , [SPEC] , : );
where SPEC array for single type is written (TYPENAME + OPT VAL pair list) as:
[TYPENAME => OPTION => VALUE, ...]
Also you can write type hierachy in nested style as:
[BASETYPE => OPT => VAL, ... , [SUBTYPE1 => OPT => VAL, ...] , [SUBTYPE2 => OPT => VAL, ... , [SUBSUBTYPE1 => OPT => VAL, ...] , [SUBSUBTYPE2 => OPT => VAL, ...] ] ]
base
Base class for newly created type. This name is preloaded before type definition (unless you specify no_require => 1).
no_require => 1
no_require
alias
To define alias(synonym) too, use this.
fields
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install YATT::Lite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm YATT::Lite
CPAN shell
perl -MCPAN -e shell install YATT::Lite
For more information on module installation, please visit the detailed CPAN module installation guide.