Chapter 1.2: Accessor

NAME

Genelet::Accessor

 

SYNOPSIS
package Foo;
use base qw(Genelet::Accessor);
Foo->setup_accessors( %init_hash );

 

DESCRIPTION

By inheriting your class from Genelet::Accessor, or one of its children such as Genelet::Model and Genelet::Filter, you can generate Getter and Setter for class attributes and initialize their values.

 

FUNCTION
__PACKAGE__->setup_accessors( %hash );

The keys and values in hash are the attributes and their default values. For example,

__PACKAGE__->setup_accessors( exmpl=>"some string" );

You can get it as $self->exmpl() resulting in “some string”. Or set it up as $self->exmp(“other”).

 

MULTI-LEVEL INHERITANCES

Setting up an attribute value via setup_accessors will override that in parents.