NAME

Config::Tree::Base - Base class for Config::Tree classes

SYNOPSIS

# Moose-speak
extends 'Config::Tree::Base';

DESCRIPTION

This is the base class for Config::Tree classes.

ATTRIBUTES

METHODS

get_tree_for($wanted_path)

Will be called whenever the tree is wanted (e.g. by get()). Should return an list ($tree_path, $tree, $mtime). For small trees that are loaded entirely into memory, $tree_path will be '/' (meaning the whole tree is retrieved). For large trees, when $wanted_path = '/foo/bar', get_tree_for() might return $tree_path = '/foo' which means only the '/foo' branch is loaded.

In other words, $tree_path can be a parent of $wanted_path. get_tree_for() is called with $wanted_path argument to allow each source to only return a subtree.

The default implementation will call _get_tree() which should return the whole tree and then _validate_tree(). Large tree classes (e.g. tree from database or directory) can override this method to be able to load only parts of the tree as needed.

save()

Save configuration. Does nothing if configuration is never modified (by set() method). Dies if config is read only (ro property is true).

getcwd()

Returns the current absolute position.

pushd([$new_dir])

Save the current position into stack, optionally change to $new_dir. Concept is like Unix shell's "pushd" command.

popd()

Go back to the last saved position. Concept is like Unix shell's "popd" command.

cd($path)

Change position to $path. $path is absolute or relative path.

normalize_path($path)

$path is a string, which can contain absolute (e.g. "/foo/bar") or relative path (e.g., "../bar"). Returns array of path elements, which is its normalized form.

get($path)

Get config variable for $path.

The default implementation can handle hash prefix a la Data::PrefixMerge.

path_is_excluded($normalized_path)

set($path, $val)

unset($path)

SEE ALSO

Data::Schema, Data::PrefixMerge.

AUTHOR

Steven Haryanto, <stevenharyanto at gmail.com>

COPYRIGHT & LICENSE

Copyright 2009 Steven Haryanto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.