The accessor keyword tells your ORM to use an alternate name for the dual use get/set accessor for a field. This is useful if you want to use the field's name for some other method. I do this for date beautification, among other things. So, as in the example below, I might have a field like this:
accessor
field birth_day { is date; label `Birth Day`; html_form_type text; accessor birth_date_acc; }
Then in the model stub for this table I can add a method called birth_date. Anyone calling it gets the formatting of my choosing:
sub birth_date { my $row = shift; my $value = $row->birth_date_acc( @_ ); return beautify_date( $value ); }
Note that I carefully dispatch to the real accessor first, then pretty up the date.
To see an example, build:
bigtop -c example.bigtop all
From the newly created Kids subdirectory, look in lib/Kids/Model/GEN/child.pm for a special add_columns statement for birth_day.
add_columns
birth_day
To install Bigtop, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bigtop
CPAN shell
perl -MCPAN -e shell install Bigtop
For more information on module installation, please visit the detailed CPAN module installation guide.