The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

CatalystX::Usul::Model::Config - Read and write configuration files

Version

Describes v0.17.$Rev: 1 $

Synopsis

   package YourApp;

   use Catalyst qw(ConfigComponents...);

   __PACKAGE__->config(
     'Model::Config'   => {
        parent_classes => q(CatalystX::Usul::Model::Config) }, );

Description

Provides CRUD methods for read and write configuration files. For each schema a subclass is defined that inherits from this class

Configuration and Environment

Defines the following list of attributes;

classes

A hash ref which defaults to an empty ref. Keyed by field name its values are CSS class names which are applied to the field's input element

create_msg_key

A simple string which defaults to NUL. The message that is added to the result div when a new configuration element is created

ctrldir

Defaults to $self->usul->config->ctrldir the location of the configuration files

default_ns

A non empty simple string which defaults to default. The default namespace

delete_msg_key

A simple string which defaults to NUL. The message that is added to the result div when a configuration element is deleted

domain_attributes

Overrides the base class default with { storage_class = q(Any) }>. Passed to the domain class each time an instance is created

domain_class

Overrides the base class default with CatalystX::Usul::Config. The classname of the domain model

extension

Defaults to $self->usul->config->extension the default filename extension for configuration files

fields

An array ref of strings which defaults to the empty list. If empty the domain models source attributes are used instead. It is the list of fields used on the form for the configuration element

keys_attr

A simple string which defaults to NUL. The attribute name that is used as the key for the configuration element

ns_key

A non empty simple string which defaults to namespace. A stash key whose stashed value is a list of controller namespaces

phase

Defaults to $self->usul->config->phase the type number for this installation

prompts

A hash ref of prompts used to override the default one on a per field basis. Keyed by attribute name

table_class

A loadable class which defaults to Class::Usul::Response::Table. The class of the table object passed to HTML::FormWidgets when the configuration element contains a table

table_data

A hash ref which defaults to an empty hash. The data for a table object

typelist

A hash ref which defaults to an empty hash. The list of type for each field

update_msg_key

A simple string which defaults to NUL. The message that is added to the result div when a configuration element is updated

Subroutines/Methods

build_per_context_instance

Creates a new domain_class object and makes a copy of the request object

config_form

   $self->config_form( $namespace, $config_element_name );

Creates the form to edit a configuration element

create

   $config_element_name = $self->create( $namespace, $args );

Creates a new element. The $args hash requires these keys; file the name of the file to edit, name the name of the element to edit and fields is a hash containing the attributes of the new element

create_or_update

   $config_element_name = $self->create_or_update( $namespace, $args );

Creates a new element if one does not exist or updates the existing one if it does exist

delete

   $self->delete( $args );

Deletes an element

find

   $config_object = $self->find( $namspace, $name );

Returns the requested configuration element if it exists

list

   $selected_list_and_named_element = $self->list( $namespace, $name );

Retrieves the named element and a list of elements

load

   $config = $self->load( @{ $files } );

Loads the required configuration files. Returns a hash ref

load_per_request_config

   $self->load_per_request_config;

Loads the config data for the current request. The data is split across six files; one for OS dependant data, one for this phase (live, test, development etc.), default data and language dependant default data, data for the current controller and it's language dependant data. This information is cached

Data in the globals attribute is raised to the top level of the stash and the globals attribute deleted

push_attribute

   $count = $self->push_attribute( $namespace, $args );

Add new items to an attribute list. The $args hash requires these keys; file the name of the file to edit, name the name of the element to edit, list the attribute of the named element containing the list of existing items, req the request object and field the field on the request object containing the list of new items

   @elements = $self->search( $args );

Searches the given file for elements matching the given criteria. Returns an array of element objects

splice_attribute

   $count = $self->splice_attribute( $namespace, $args );

Removes items from an attribute list

update

   $config_element_name = $self->update( $namespace, $args );

Updates the named element

update_list

   $bool = $self->update_list( $namespace, $args );

Will push/splice attributes to/from the selected list

Diagnostics

None

Dependencies

CatalystX::Usul::Model
CatalystX::Usul::TraitFor::Model::StashHelper
CatalystX::Usul::TraitFor::Model::QueryingRequest
CatalystX::Usul::Moose
Class::Usul::File
Class::Usul::Response::Table
Config

Incompatibilities

There are no known incompatibilities in this module

Bugs and Limitations

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Copyright (c) 2014 Peter Flanigan. All rights reserved

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

This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE