From 13075a63e6d39d2b6b93587834c08c1be243a40f Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 6 Jul 2009 13:23:55 +0000 Subject: 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 --- xpp/perl_modules/Dahdi/Config/Params.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'xpp/perl_modules') 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 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 method: =item * All these values are overriden by directives in the config file. +=item * Calling it with C 1> option, returns C 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($) { -- cgit v1.2.3