NAME
Process::Packageable - Process that can be packaged with its dependencies
SYNOPSIS
# In MyPackageableProcess.pm:
package MyPackageableProcess;
use strict;
use base
'Process',
'Process::Storable', # or other Process::Serializable subclass
'Process::Packageable',
;
# Add your dependencies to your parent class's if you like
sub dependencies {
my $self = shift;
return(
$self->SUPER::dependencies(),
'Some::Class::Name' => '1.01',
'Another::Class' => '0.03',
...
);
}
# Now as usual for Process subclasses:
sub new {
...
}
sub prepare {
...
}
sub run {
...
}
# in user code:
my $object = MyPackageableProcess->new( foo => 'bar' );
# Find out about the object's explicit class dependencies
my @dependencies = $object->dependencies();
# key/value pairs in @dependencies, but with duplicates
DESCRIPTION
Process::Packageable
provides a role (an additional interface and set of rules) that allow for Process objects to be packaged into a Process::Packaged object together with the Process
object's dependencies.
Inheriting from Process::Packageable
in a Process
subclass, you agree to implement the dependencies
method as documented below. A sample dependencies
method which just requires a minimum perl version (5.005) is implemented by Process::Packageable
.
In addition, you need to make sure that any dependencies of your subclass can be correctly identified by the Module::ScanDeps module. In order to identify your Process's dependencies, a run of Module::ScanDeps
should suffice.
Furthermore, your subclass needs to be serializable. That means it has to be a subclass of Process::Serializable. You may either implement your own serialization code or inherit from Process::Storable, Process::YAML or other Process::Serializable
subclasses.
Note on Process::Packaged
Process::Packaged
is not part of the Process
distribution.
A Process::Packaged
object can be "frozen" to a string, moved around, and then be "thawed" back into an object again. (A Process::Packaged
object is a Process::Serializable
object.)
During the reconstruction of the Process::Packaged
object, it extracts the dependencies of the Process::Packageable
object, checks whether the dependencies are okay, and loads the class of the packaged object.
A Process
must be packageable whenever it is serializable. Please refer to Process::Serializable for details on when that is the case.
METHODS
dependencies
my @dependency_list = $object->dependencies();
The dependencies
method returns a list of class names and respective version strings that describe the dependencies of your Process
subclass. There are no parameters to dependencies()
.
The returned list has class names and respective version strings interleaved. The classes will be mapped to distributions which will be mapped to files by Process::Packaged
.
Specifying a '0'
as a version indicates any version.
There is a special key word perl
which can be used to set a dependency on a minimum perl version. (perl isn't packaged, though.)
Dependencies on modules that are not pure Perl might not be packaged and extracted correctly.
The default implementation of dependencies
returns
'perl', '5.005'
You are expected to override it. In order to make your class subclassable, you should include the dependencies of your parent class into the returned list of dependencies. The SYNOPSIS has an example implementation.
SUPPORT
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Process
For other issues, contact the author.
AUTHOR
Adam Kennedy <adamk@cpan.org>, http://ali.as/
COPYRIGHT
Copyright 2006 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.