summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-07-06 13:23:55 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-07-06 13:23:55 +0000
commit13075a63e6d39d2b6b93587834c08c1be243a40f (patch)
treec0d0ce8a40a60d66701c2cac20437c967fa415fb
parent1417ff1a0c4a28fe656b5c8edb6f3a7bd7852a83 (diff)
Dahdi::Config::Params allow item() method to be used without defaults
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@6831 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--xpp/perl_modules/Dahdi/Config/Params.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/xpp/perl_modules/Dahdi/Config/Params.pm b/xpp/perl_modules/Dahdi/Config/Params.pm
index 816b5c1..dd886e7 100644
--- a/xpp/perl_modules/Dahdi/Config/Params.pm
+++ b/xpp/perl_modules/Dahdi/Config/Params.pm
@@ -18,6 +18,7 @@ Dahdi::Config::Params -- Object oriented representation of F<genconf_parameters>
use Dahdi::Config::Params;
my $params = Dahdi::Config::Params->new('the-config-file');
print $params->item{'some-key'};
+ print $params->item{'some-key', NODEFAULTS => 1};
$params->dump; # For debugging
=head1 DESCRIPTION
@@ -42,6 +43,9 @@ The access to config keys should only be done via the C<item()> method:
=item * All these values are overriden by directives in the config file.
+=item * Calling it with C<NODEFAULTS =E<gt> 1> option, returns C<undef> for keys that
+do not appear in the configuration file.
+
=back
=cut
@@ -87,9 +91,10 @@ sub new($$) {
return $self;
}
-sub item($$) {
+sub item($$@) {
my $self = shift || die;
my $key = shift || die;
+ my %options = @_;
my %defaults = (
base_exten => '4000',
freepbx => 'no', # Better via -F command line
@@ -111,8 +116,8 @@ sub item($$) {
r2_idle_bits => '1101',
'pri_termtype' => [ 'SPAN/* TE' ],
);
-
- return (exists($self->{$key})) ? $self->{$key} :$defaults{$key};
+ return $self->{$key} if exists($self->{$key}) or $options{NODEFAULTS};
+ return $defaults{$key};
}
sub dump($) {