.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Class::Accessor::Lite 3pm" .TH Class::Accessor::Lite 3pm "2021-01-02" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::Accessor::Lite \- a minimalistic variant of Class::Accessor .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyPackage; \& \& use Class::Accessor::Lite ( \& new => 1, \& rw => [ qw(foo bar) ], \& ro => [ qw(baz) ], \& wo => [ qw(hoge) ], \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The module is a variant of \f(CW\*(C`Class::Accessor\*(C'\fR. It is fast and requires less typing, has no dependencies to other modules, and does not mess up the \f(CW@ISA\fR. .SH "THE USE STATEMENT" .IX Header "THE USE STATEMENT" The use statement (i.e. the \f(CW\*(C`import\*(C'\fR function) of the module takes a single hash as an argument that specifies the types and the names of the properties. Recognises the following keys. .ie n .IP "new => $true_or_false" 4 .el .IP "new => \f(CW$true_or_false\fR" 4 .IX Item "new => $true_or_false" the default constructor is created if the value evaluates to true, otherwise nothing is done (the default behaviour) .IP "rw => \e@name_of_the_properties" 4 .IX Item "rw => @name_of_the_properties" creates a read / write accessor for the name of the properties passed through as an arrayref .IP "ro => \e@name_of_the_properties" 4 .IX Item "ro => @name_of_the_properties" creates a read-only accessor for the name of the properties passed through as an arrayref .IP "wo => \e@name_of_the_properties" 4 .IX Item "wo => @name_of_the_properties" creates a write-only accessor for the name of the properties passed through as an arrayref .PP For more detailed explanation read the following section describing the behaviour of each function that actually creates the accessors. .SH "FUNCTIONS" .IX Header "FUNCTIONS" As of version 0.04 the properties can be specified as the arguments to the \f(CW\*(C`use\*(C'\fR statement (as can be seen in the \s-1SYNOPSIS\s0) which is now the recommended way of using the module, but for compatibility the following functions are provided as well. .SS "Class::Accessor::Lite\->mk_accessors(@name_of_the_properties)" .IX Subsection "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. .SS "Class::Accessor::Lite\->mk_ro_accessors(@name_of_the_properties)" .IX Subsection "Class::Accessor::Lite->mk_ro_accessors(@name_of_the_properties)" Same as \fBmk_accessors()\fR except it will generate read-only accessors (i.e. true accessors). If you attempt to set a value with these accessors it will throw an exception. .SS "Class::Accessor::Lite\->mk_wo_accessors(@name_of_the_properties)" .IX Subsection "Class::Accessor::Lite->mk_wo_accessors(@name_of_the_properties)" Same as \fBmk_accessors()\fR except it will generate write-only accessors (i.e. mutators). If you attempt to read a value with these accessors it will throw an exception. .SS "Class::Accessor::Lite\->\fBmk_new()\fP" .IX Subsection "Class::Accessor::Lite->mk_new()" Creates the \f(CW\*(C`new\*(C'\fR function that accepts a hash or a hashref as the initial properties of the object. .SS "Class::Accessor::Lite\->mk_new_and_accessors(@name_of_the_properties)" .IX Subsection "Class::Accessor::Lite->mk_new_and_accessors(@name_of_the_properties)" \&\s-1DEPRECATED.\s0 Use the new \*(L"use Class::Accessor::Lite (...)\*(R" style. .SH "FAQ" .IX Header "FAQ" .ie n .SS "Can I use ""Class::Accessor::Lite"" in an inherited module?" .el .SS "Can I use \f(CWClass::Accessor::Lite\fP in an inherited module?" .IX Subsection "Can I use Class::Accessor::Lite in an inherited module?" Yes in most cases, when the class object in the super class is implemented using a hashref. However you _should_ _not_ create the constructor for the inherited class by calling \f(CW\*(C`> or by \f(CW\*(C`>. The only other thing that \f(CW\*(C`Class::Accessor::Lite\*(C'\fR does is to set up the accessor functions for given property names through a blessed hashref. .SS "What happens when passing more than one arguments to the accessor?" .IX Subsection "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. .PP .Vb 2 \& my @data = (1, 2, 3); \& $obj\->someproperty(@data); \& \& $obj\->someproperty\->[2]++; # $data[3] is incremented .Ve .PP In general, you should pass an arrayref to set an arrayref to a property. .PP .Vb 2 \& my @data = (1, 2, 3); \& $obj\->someproperty([ @data ]); # save a copy using arrayref \& \& $obj\->someproper\->[2]++; # @data is not modified .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Class::Accessor .PP Class::Accessor::Lite .SH "AUTHORS" .IX Header "AUTHORS" Copyright (C) 2008 \- 2010 Kazuho Oku .SH "LICENSE" .IX Header "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.