Apache2-ASP

 view release on metacpan or  search on metacpan

lib/Apache2/ASP/ConfigNode/System/Settings.pm  view on Meta::CPAN


package Apache2::ASP::ConfigNode::System::Settings;

use strict;
use warnings 'all';
use base 'Apache2::ASP::ConfigNode';


#==============================================================================
sub new
{
  my $class = shift;
  
  my $s = $class->SUPER::new( @_ );
  
  return $s;
}# end new()


#==============================================================================
sub AUTOLOAD
{
  my $s = shift;
  our $AUTOLOAD;
  
  my ($name) = $AUTOLOAD =~ m/([^:]+)$/;
  
  my ($val) = grep {
    $_->{name} eq $name
  } @{ $s->{setting} };
  
#  defined($val) or return;
  return $val->{value};
}# end AUTOLOAD()

1;# return true:

=pod

=head1 NAME

Apache2::ASP::ConfigNode::System::Settings - The $Config->system->settings collection

=head1 SYNOPSIS

Given an XML config file like this:

  <?xml version="1.0"?>
  <config>
    ...
    <system>
      ...
      <settings>
        ...
        <setting>
          <name>encryption_key</name>
          <value>k23j4hkj234hkj23h4kj2h34kj2h34</value>
        </setting>
        ...
      </settings>
      ...
    </system>
    ...
  </config>

You would access the data like this:

  my $encryption_key = $Config->system->settings->encryption_key;

=head1 DESCRIPTION

Settings are an eventual fact of life in any sufficiently complex web application.

This package provides read-only access to the settings you describe in your XML



( run in 0.449 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )