StorageBase - base class for filter storage plugins
package List::Filter::Storage::NewFormat; use base qw( List::Filter::StorageBase ); sub init { } sub lookup { # ... } sub save { # ... } sub list_filters { # ... } 1;
This is module is purely an interface, which the storage plugins are intended to inherit from. The documentation of this module is thus oriented toward people interested in writing new storage plugins, see the existing plugins for documentation on how to use them.
The main fields inside the object:
In the case of DBI, this will be the database connection string, indicating the DBD driver and the database name.
A user name, when required to make the connection.
A password, to go with the user name.
A hash reference of additional attributes to be used by the storage back-end in any way that seems appropriate.
In the case of DBI, this hash ref might contain something like this:
{ RaiseError => 1, AutoCommit => 1 }
(Though there's no particular point in manipulating AutoCommit with storage needs this simple).
The type of the filters being stored (e.g. 'filter', 'transform'). Not to be confused with the data storage format (e.g 'YAML', 'DBI')
A catch-all hash reference intended to be used primarily for internal storage purposes by the subclasses, e.g. in the case of YAML, this will contain a reference to the contents of an entire YAML file that has been slurped into memory. Writing additional accessors for the data inside of "extra" is strongly advised, to make it easier to modifiy the internal structure at a later date.
There are two main methods that need to be implemented:
Instantiates a new object.
Takes an optional hashref as an argument, with named fields identical to the names of the object attributes.
With no arguments, the newly created filter will be empty.
Initialize object attributes and then lock them down to prevent accidental creation of new ones.
Note: there is no leading underscore on name "init", though it's arguably an "internal" routine (i.e. not likely to be of use to client code).
Optionally, a plugin may run additional initialization code inside of an init method that overrides this stub.
From the type of the stored filters (e.g. 'filter', 'transform'), determine the appropriate class.
This implements the convention: List::Filter::<type>, except that for type 'filter' the class is just "List::Filter".
Given a name, returns the first filter found with a matching name.
Given a filter saves it to the storage location indicated by the "write_storage" setting of the List::Filter::Storage object, using the name indicated by the "name" field inside of the filter.
Returns a list of all available filters.
Getter for object attribute connect_to
Getter for object attribute owner
Setter for object attribute set_owner
Getter for object attribute password
Setter for object attribute set_password
Setter for object attribute set_connect_to
Getter for object attribute attributes
Setter for object attribute set_attributes
Getter for object attribute type
Setter for object attribute set_type
Getter for object attribute extra
Setter for object attribute set_extra
List::Filter List::Filter::Storage::YAML List::Filter::Storage::DBI
Joseph Brenner, <doom@kzsu.stanford.edu>, 18 May 2007
Copyright (C) 2007 by Joseph Brenner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.
None reported... yet.
To install List::Filter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::Filter
CPAN shell
perl -MCPAN -e shell install List::Filter
For more information on module installation, please visit the detailed CPAN module installation guide.