[svn-commits] tzafrir: tools/trunk r6831 - /tools/trunk/xpp/perl_modules/Dahdi/Config/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 6 08:23:58 CDT 2009


Author: tzafrir
Date: Mon Jul  6 08:23:55 2009
New Revision: 6831

URL: http://svn.asterisk.org/svn-view/dahdi?view=rev&rev=6831
Log:
Dahdi::Config::Params allow item() method to be used without defaults

Modified:
    tools/trunk/xpp/perl_modules/Dahdi/Config/Params.pm

Modified: tools/trunk/xpp/perl_modules/Dahdi/Config/Params.pm
URL: http://svn.asterisk.org/svn-view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Config/Params.pm?view=diff&rev=6831&r1=6830&r2=6831
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Config/Params.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Config/Params.pm Mon Jul  6 08:23:55 2009
@@ -18,6 +18,7 @@
  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
@@ -41,6 +42,9 @@
 =item * It contains all hard-coded defaults.
 
 =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
 
@@ -87,9 +91,10 @@
 	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 @@
 			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($) {




More information about the svn-commits mailing list