NAME

Class::Accessor::Lite - a minimalistic variant of Class::Accessor

SYNOPSIS

package MyPackage;

use Class::Accessor::Lite;

# make accessors: "foo" and "bar"
Class::Accessor::Lite->mk_accessors(qw(foo bar));

# make accessors and the constructor
Class::Accessor::Lite->mk_new_and_accessors(qw(foo bar));

DESCRIPTION

This is a minimalitic variant of Class::Accessor and its alikes.

It is intended to be standalone and minimal, so that it can be copy & pasted into individual perl script files.

FUNCTIONS

Class::Accessor::Lite->mk_accessors(@name_of_the_properties)

Creates an accessor in current package under the name specified by the arguments that access the properties (of a hashref) with the same name.

Class::Accessor::Lite->mk_new_and_accessors(@name_of_the_properties)

Creates the new function in addition to the accessors. The function will accept a hash or a hashref as the initial properties of the object. The default values of the properties are undef.

FAQ

What happens when passing more than one arguments to the accessor?

When the accessor built by Class::Accessor::Lite is given more than one arguments, a reference to the arguments will be saved as an arrayref. This behaviour might not be necessary but is implemented as is to maintain compatibility with Class::Accessor::Fast.

my @data = (1, 2, 3);
$obj->someproperty(@data);

$obj->someproperty->[2]++; # $data[3] is incremented

In general, you should pass an arrayref to set an arrayref to a property.

my @data = (1, 2, 3);
$obj->someproperty([ @data ]); # save a copy using arrayref

$obj->someproper->[2]++; # @data is not modified

SEE ALSO

Class::Accessor

Class::Accessor::Lite

AUTHORS

Copyright (C) 2008 - 2010 Kazuho Oku

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.