NAME
Class::new - Pragma to implement constructor methods
VERSION 1.12
Included in OOTools 1.12 distribution. The distribution includes:
Class::new
Pragma to implement constructor methods
Class::props
Pragma to implement lvalue accessors with options
Object::props
Pragma to implement lvalue accessors with options
SYNOPSIS
Class
package MyClass ;
# implement constructor without options
use Class::new ;
# this will be called by default if defined
sub _init
{
my ($s, @args) = @_
....
}
# with options
use Class::new name => 'new_object'
init => [ qw( init1 init2 ) ] ;
Usage
my $object = MyClass->new(digits => '123');
DESCRIPTION
This pragma easily implements lvalue constructor methods for your class.
You can completely avoid to write the constructor by just using it and eventually declaring the name and the init methods to call.
INSTALLATION
- Prerequisites
-
Perl version >= 5.6.1
- CPAN
-
perl -MCPAN -e 'install OOTools'
- Standard installation
-
From the directory where this file is located, type:
perl Makefile.PL make make test make install
OPTIONS
- name
-
The name of the constructor method. If you omit this option the 'new' name will be used by default.
- init
-
use this option if you want to call other method in your class to further initialize the object. You can group method by passing a reference to an array containing the methods names.
After the assignation and validation of the properties, the initialization methods in the
init
option will be called. Each init method will receive the blessed object passed in$_[0]
and the other (original) parameter in the remaining@_
.
SUPPORT and FEEDBACK
I would like to have just a line of feedback from everybody who tries or actually uses this module. PLEASE, write me any comment, suggestion or request. ;-)
More information at http://perl.4pro.net/?Class::new.
AUTHOR
Domizio Demichelis, <dd@4pro.net>.
COPYRIGHT
Copyright (c)2002 Domizio Demichelis. All Rights Reserved. This is free software; it may be used freely and redistributed for free providing this copyright header remains part of the software. You may not charge for the redistribution of this software. Selling this code without Domizio Demichelis' written permission is expressly forbidden.
This software may not be modified without first notifying the author (this is to enable me to track modifications). In all cases the copyright header should remain fully intact in all modifications.
This code is provided on an "As Is'' basis, without warranty, expressed or implied. The author disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness, in no event shall the author, be liable for any special, indirect or consequential damages or any damages whatsoever including but not limited to loss of use, data or profits. By using this software you agree to indemnify the author from any liability that might arise from it is use. Should this code prove defective, you assume the cost of any and all necessary repairs, servicing, correction and any other costs arising directly or indrectly from it is use.
The copyright notice must remain fully intact at all times. Use of this software or its output, constitutes acceptance of these terms.
BUGS
None known, but the module is not completely tested.
CREDITS
Thanks to Juerd Waalboer (http://search.cpan.org/author/JUERD) that with its Attribute::Property inspired the creation of this distribution.