The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Class::Framework - Interface which combines Class::Accessor, fields, and Class::MethodVars to ease creating a Class.

SYNOPSIS

  package Pixel;
  use warnings; # You always do this don't you...
  use strict; # This module is strict-safe (unless you use -varargs, but see Class::MethodVars for that).

  use Class::Framework -fields=>qw( x y colour );

  sub _INIT :Method {
        unless (grep { this->colour eq $_ } qw( red green blue yellow white black )) {
                require Carp;
                Carp::croak "${^_colour} is not a recognised colour!";
        }
  }

  sub print_To_Array($) :Method(. arrayref) {
    ${^_arrayref}->[this->y]->[this->x] = this->colour;
  }

  1;
  __END__

DESCRIPTION

This package is intended to allow you to rapidly create a class using fields with Class::Accessor generated accessors along with Class::MethodVars methods.

Inheriting from other classes built using Class::Framework or Class::MethodVars will automatically inherit their fields. You can inherit from any other class with the -base=> option to save an extra "use base" line.

CATCHES

The following items are things that you may find unusual when using Class::Framework to make your class. Most of the time they should not be a problem for you.

"@ISA"

You may notice "Class::Framework::New" and/or "Class::MethodVars::_ATTRS" in your @ISA. The former provides the default new() function (see below), the latter provides the :Method and :ClassMethod attributes.

"new()"

A default "new()" method is provided which will accept a HASH or HASHREF as parameters to define initial values. It will also call ->_INIT(@_) on the resulting object allowing you to create a :Method which will initialise an object. This is all intended to neatly glue together fields::new and Class::Accessors with the minimum of fuss from a user's point of view. (Don't forget to call this->NEXT::_INIT(@_) for the parent class init if appropriate!). Because this is inherited from Class::Framework::New you can create your own new() to do your own thing.

SEE ALSO

See Class::MethodVars for the parameters on the use line. All options except -base are passed through to that module. See Class::Accessor used by this module.

AUTHOR

Copyright 2006 Timothy Hinchcliffe <cpan@spidererrol.co.uk>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. That means either (a) the GNU General Public License or (b) the Artistic License.