NAME

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

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;

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.

METHODS

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

cleanup ()

Calls cleanup method on all embedded configurations if it is available. Order of calls is random.

embed (%)

This method allows to embed other configuration objects into Config. After embedding certain methods of embedded object become available as Config methods. For example, if you embed Web::Config into Config and Web::Config provides a method called cgi(), then you will be able to call that method on Config:

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

$config->embed('Web::Config' => $webconfig);

my $cgi=$config->cgi();

In order to support that hte object being embedded must have a method embeddable_methods() that returns an array of method names to be embedded.

sub embeddable_methods ($) {
    my $self=shift;
    return qw(cgi add_cookie del_cookie);
}

The idea behind embedding is to allow easy access to arbitrary context description objects (Configs). For example XAO::FS would provide its own config that creates and caches its database handler. Some other database module might provide its own config if for some reason XAO::FS can't be used.

embedded ($)

Returns a reference to a previously embedded object by name. Can be used to call non-embedded method on that object.

init (%)

Default method for project specific Config implementation initialization. This method would normally be called by various handlers after creating configuration and before making it current. It calls init() method on all embedded configs in unpredictable order.

new ()

Creates new instance of abstract Config.

AUTHOR

Copyright (c) 2001 XAO Inc.

Author is Andrew Maltsev <am@xao.com>.