NetSDS::Class::Abstract - superclass for all NetSDS APIs
package MyClass; use base 'NetSDS::Class::Abstract'; __PACKAGE__->mk_accessors(qw/my_field/); sub error_sub { my ($this) = @_; if (!$this->my_field) { return $this->error("No my_field defined"); } } 1;
NetSDS::Class::Abstract is a superclass for all other NetSDS classes, containing the following functionality:
NetSDS::Class::Abstract
common class constructor
safe modules inclusion
class and objects accessors and cloning;
error handling;
All other class/object APIs should inherit this class to use it's functionality in standard way.
Common constructor for NetSDS classes.
my $object = NetSDS::SomeClass->new(%options);
Constructor may be overwriten in inherited classes and usually is. Parameters for constructor may be given as hash or hash reference.
Class->mk_class_var(@variables);
This creates accessor/mutator methods for each named class variable.
Invoke modules from list given in parameters.
Return TRUE in case of success or FALSE if failed.
TRUE
FALSE
Return non object copy of object data structure.
$copy = $obj->unbless(); $same = $obj->unbless( 1 );
This method returns serialized copy of object.
Paramters: serialized object as string
Returns: object
my $obj = NetSDS::SomeClass->deserialize($str);
Save serialized object to file
This method allows to set class logger (NetSDS::Logger object)
Paramters: log level, log message
$obj->log("info", "We still alive");
if (error_occured()) { $this->error_code(1234); # secret error status return $this->error("Oops! We have a 1234 error!"); }
See samples directory and other NetSDS moduleis for examples of code.
samples
NetSDS
Unknown yet
Class::Accessor, Class::Accessor::Class, Clone, Class::ErrorHandler
None
Michael Bochkaryov <misha@rattler.kiev.ua>
To install NetSDS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm NetSDS
CPAN shell
perl -MCPAN -e shell install NetSDS
For more information on module installation, please visit the detailed CPAN module installation guide.