Query: ropkg::object
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
RoPkg::Object(3pm) User Contributed Perl Documentation RoPkg::Object(3pm)NAMERoPkg::ObjectVERSION0.3.2DESCRIPTIONRoPkg::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.SYNOPSISpackage RoPkg::Person; use strict; use warnings; use RoPkg::Object; use base qw(RoPkg::Object); $pf = { FirstName => 'A person first name', LastName => 'A person last name' }; 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('John'); $p->LastName('Doe'); print $p->FirstName,' ',$p->LastName,$RS; } main();SUBROUTINES/METHODS All methods (besides new()) 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. new() The class contructor. At this moment the constructor does nothing (besides bless). key($value) Search into methods list for a entry those value is $value. Returns the method name or 0 if such a method was not found. 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)). 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.SUBCLASSINGAs said before, this module is specially used as a base class for those objects with many SET/GET methods. How can you use this class in your project ? As seen in the SYNOPSIS, when you create the new class, in the class constructor you call for $self->_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: FirstName => q{-} This means, that _inject will create a get/set method named FirstName. There are some key values with special meaning: *) __exclude__ - the method with this value will not be created by _inject *) q{} - the method with this value will not be created by _inject 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 _inject() has the following code: sub { my ($self, $pval) = @_; if ( !blessed($self) ) { OutsideClass->throw('Called outside class instance'); } if ( defined $pval) { $self->{$method_name} = $pval; } return $self->{$method_name}; };DEPENDENCIESRoPkg::Object require perl 5.008 or later and the Scalar::Util module. To run the tests you also need: *) Test::More *) Test::Pod *) Test::Pod::CoverageDIAGNOSTICSThis module is subject of tests. To run those tests, unpack the source and use the following command: make testCONFIGURATION AND ENVIRONMENTThis module does not use any configuration file or environment variables.INCOMPATIBILITIESNone known to the authorBUGS AND LIMITATIONSNo 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 "injects" the new methods.PERL CRITICThis module is perl critic level 1 compliant with 2 exceptions.AUTHORSubredu Manuel <diablo@iasi.roedu.net>LICENSE AND COPYRIGHTCopyright (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 LICENSE file contains the full text of the license. perl v5.8.8 2006-06-09 RoPkg::Object(3pm)
Related Man Pages |
---|
ropkg::dbobject(3pm) - debian |
ropkg::rsync::conffile(3pm) - debian |
ropkg::simba(3pm) - debian |
ropkg::simba::commands(3pm) - debian |
ropkg::simba::exclude(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
How do i start this? (Help) |
Evaluated variables in PHP |
Help with splitting and rearranging a field in awk |
How to remove new line characters from data rows in a Pipe delimited file? |