ASP/ConfigNode/System/Settings.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 26 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
AUTOLOAD
2.0
BEGIN
2.0
CRAP 2.0
1  
2 package Apache2::ASP::ConfigNode::System::Settings;
3  
4 use strict;
5 use warnings 'all';
6 use base 'Apache2::ASP::ConfigNode';
7  
8  
9 #==============================================================================
10 sub new
11 {
12 my $class = shift;
13
14 my $s = $class->SUPER::new( @_ );
15
16 return $s;
17 }# end new()
18  
19  
20 #==============================================================================
21 sub AUTOLOAD
22 {
23 my $s = shift;
24 our $AUTOLOAD;
25
26 my ($name) = $AUTOLOAD =~ m/([^:]+)$/;
27
28 my ($val) = grep {
29 $_->{name} eq $name
30 } @{ $s->{setting} };
31
32 # defined($val) or return;
33 return $val->{value};
34 }# end AUTOLOAD()
35  
36 1;# return true:
37  
38 =pod
39  
40 =head1 NAME
41  
42 Apache2::ASP::ConfigNode::System::Settings - The $Config->system->settings collection
43  
44 =head1 SYNOPSIS
45  
46 Given an XML config file like this:
47  
48 <?xml version="1.0"?>
49 <config>
50 ...
51 <system>
52 ...
53 <settings>
54 ...
55 <setting>
56 <name>encryption_key</name>
57 <value>k23j4hkj234hkj23h4kj2h34kj2h34</value>
58 </setting>
59 ...
60 </settings>
61 ...
62 </system>
63 ...
64 </config>
65  
66 You would access the data like this:
67  
68 my $encryption_key = $Config->system->settings->encryption_key;
69  
70 =head1 DESCRIPTION
71  
72 Settings are an eventual fact of life in any sufficiently complex web application.
73  
74 This package provides read-only access to the settings you describe in your XML
75 config file.
76
77 =head1 BUGS
78
79 It's possible that some bugs have found their way into this release.
80
81 Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Apache2-ASP> to submit bug reports.
82
83 =head1 HOMEPAGE
84
85 Please visit the Apache2::ASP homepage at L<http://www.devstack.com/> to see examples
86 of Apache2::ASP in action.
87
88 =head1 AUTHOR
89
90 John Drago <jdrago_999@yahoo.com>
91
92 =head1 COPYRIGHT AND LICENSE
93
94 Copyright 2007 John Drago, All rights reserved.
95
96 This software is free software. It may be used and distributed under the
97 same terms as Perl itself.
98
99 =cut
100