NAME

Pangloss::accessors - create accessors in Pangloss objects.

SYNOPSIS

use Pangloss::accessors;

package Foo;
use accessors qw( foo bar baz );

sub my_method {
    my $self = shift;
    $self->foo( shift )
         ->bar( shift );
    print $self->foo, $self->bar, if $self->baz;
}

DESCRIPTION

Create accessors in a class's namespace of the style:

sub $property {
    my $self = shift;
    if (@_) { $self->{"-$property"} = shift; return $self; }
    else    { return $self->{"-$property"}; }
}

So that you don't have to write the above 1000 times. Written in such a way that you can cascade your sets:

my $foo = Foo->new->bar(1)->baz(2);

Which can be quite useful.

NOTES

Installed as the 'accessor' pragma, but the module lives under the Pangloss namespace so we avoid invading the perl core.

THANKS

Inspired from code by Michael G. Schwern.

AUTHOR

Steve Purkis <spurkis@quiup.com>

SEE ALSO

Pangloss::Object, Pangloss::Error

Class::Accessor