.\" 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 "RoPkg::Object 3pm" .TH RoPkg::Object 3pm "2021-12-26" "perl v5.32.1" "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" .Vb 1 \& RoPkg::Object .Ve .SH "VERSION" .IX Header "VERSION" 0.3.2 .SH "DESCRIPTION" .IX Header "DESCRIPTION" RoPkg::Object is a general pourpose module, designed for Get/Set objects on which you don't want to spend your time writing annoying Get/Set methods. The primary use of the module is to be a base class. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package RoPkg::Person; \& \& use strict; \& use warnings; \& \& use RoPkg::Object; \& \& use base qw(RoPkg::Object); \& \& $pf = { \& FirstName => \*(AqA person first name\*(Aq, \& LastName => \*(AqA person last name\*(Aq \& }; \& \& sub new { \& my ($class, %opt) = @_; \& my $self; \& \& $self = $class\->SUPER::new(%opt); \& $self\->{methods} = $pf; \& $self\->_inject(); \& \& return $self; \& } \& \& 1; \& \& tester.pl \& #!/usr/bin/perl \& \& use strict; \& use warnings; \& \& use English qw(\-no_match_vars); \& use RoPkg::Person; \& \& sub main { \& my $p = new RoPkg::Person(); \& $p\->FirstName(\*(AqJohn\*(Aq); \& $p\->LastName(\*(AqDoe\*(Aq); \& \& print $p\->FirstName,\*(Aq \*(Aq,$p\->LastName,$RS; \& } \& \& main(); .Ve .SH "SUBROUTINES/METHODS" .IX Header "SUBROUTINES/METHODS" All methods (besides \fBnew()\fR) raise OutsiteClass exception if called outside a class instance. Each method, may raise other exceptions. Please read the documentation of that method for aditional information. .SS "\fBnew()\fP" .IX Subsection "new()" The class contructor. At this moment the constructor does nothing (besides bless). .SS "key($value)" .IX Subsection "key($value)" Search into methods list for a entry those value is \f(CW$value\fR. Returns the method name or 0 if such a method was not found. .SS "\fBmethods()\fP" .IX Subsection "methods()" In list context this method will return a list of method names. In scalar context returns just the number of methods. Please note that only the valid methods are considered (tested with can($method_name)). .SS "chkp(@plist)" .IX Subsection "chkp(@plist)" Check the current object if the parameters specified in the list are defined. If a parameter is not defined a Param::Missing exception is raised. .SH "SUBCLASSING" .IX Header "SUBCLASSING" As said before, this module is specially used as a base class for those objects with many \s-1SET/GET\s0 methods. How can you use this class in your project ? As seen in the \s-1SYNOPSIS,\s0 when you create the new class, in the class constructor you call for \f(CW$self\fR\->_inject method, who create (at runtime) the new methods. The list of methods who are gonna be created is actually a hash reference. A method can be specified like this: .PP .Vb 1 \& FirstName => q{\-} .Ve .PP This means, that _inject will create a get/set method named FirstName. There are some key values with special meaning: .IP "*) _\|_exclude_\|_ \- the method with this value will not be created by _inject" 2 .IX Item "*) __exclude__ - the method with this value will not be created by _inject" .PD 0 .IP "*) q{} \- the method with this value will not be created by _inject" 2 .IX Item "*) q{} - the method with this value will not be created by _inject" .PD .PP If a existing method is available in the class and is also included in the list of methods who will be created by _inject, that method will be ignored by _inject. Each method created by \fB_inject()\fR has the following code: .PP .Vb 2 \& sub { \& my ($self, $pval) = @_; \& \& if ( !blessed($self) ) { \& OutsideClass\->throw(\*(AqCalled outside class instance\*(Aq); \& } \& \& if ( defined $pval) { \& $self\->{$method_name} = $pval; \& } \& return $self\->{$method_name}; \& }; .Ve .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" RoPkg::Object require perl 5.008 or later and the Scalar::Util module. To run the tests you also need: .IP "*) Test::More" 3 .IX Item "*) Test::More" .PD 0 .IP "*) Test::Pod" 3 .IX Item "*) Test::Pod" .IP "*) Test::Pod::Coverage" 3 .IX Item "*) Test::Pod::Coverage" .PD .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" This module is subject of tests. To run those tests, unpack the source and use the following command: make test .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" This module does not use any configuration file or environment variables. .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" None known to the author .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" No known bugs. If you find one please send a detailed report to me. Please note that the methods are not automatically created. One must manual call (inside the child object) the method who \&\*(L"injects\*(R" the new methods. .SH "PERL CRITIC" .IX Header "PERL CRITIC" This module is perl critic level 1 compliant with 2 exceptions. .SH "AUTHOR" .IX Header "AUTHOR" Subredu Manuel .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright (C) 2005 Subredu Manuel. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The \s-1LICENSE\s0 file contains the full text of the license.