XAO-Base

 view release on metacpan or  search on metacpan

lib/XAO/DO/Config.pm  view on Meta::CPAN

=head1 NAME

XAO::DO::Config - Base object for all configurations

=head1 SYNOPSIS

Useful in tandem with XAO::Projects to describe contexts.

 use XAO::Projects qw(:all);

 my $config=XAO::Objects->new(objname => 'Config',
                              sitename => 'test');

 create_project(name => 'test',
                object => $config,
                set_current => 1);

 my $webconfig=XAO::Objects->new(objname => 'Web::Config');
 my $fsconfig=XAO::Objects->new(objname => 'FS::Config');

 $config->embed(web => $webconfig,
                fs => $fsconfig);

 # Now we have web and fs methods on the config itself:
 #
 my $cgi=$config->cgi;
 my $odb=$config->odb;

=head1 DESCRIPTION

This object provides storage for project specific configuration
variables and clipboard mechanism.

It can ``embed'' other configuration objects that describe specific
parts of the system -- such as database, web or something else. This is
done by using method embed() -- see below.

=head1 METHODS

XAO::DO::Config provides the following methods:

=over

=cut

###############################################################################
package XAO::DO::Config;
use strict;
use XAO::Utils;
use XAO::Objects;
use XAO::Cache;

use base XAO::Objects->load(objname => 'Atom');

###############################################################################
# Prototypes
#
sub cache ($%);
sub cleanup ($;@);
sub embed ($%);
sub embedded ($$);
sub is_embedded ($$);
sub new ($);

###############################################################################

=item cache (%)

Creates or retrieves a cache for use in various other XAO objects.
Arguments are directly passed to XAO::Cache's new() method (see
L<XAO::Cache>).

The 'name' argument is required and is used to identify the requested
cache. If a cache with the same name was requested before its previously
created object is returned and all new arguments are silently ignored
without making sure they match the previous request.

B<Note:> Retrieve method SHOULD NOT rely on any locally available
lexical variables, they will be taken from whatever scope existed first
time cache() was called!

Example:

 my $cache=$self->cache(
     name        => 'fubar',
     retrieve    => \&real_retrieve,
     coords      => ['foo','bar'],
     expire      => 60
 );

Caches are kept between executions in mod_perl environment.



( run in 2.208 seconds using v1.01-cache-2.11-cpan-84e82930d8c )