summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:06:56 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:06:56 -0700
commitc3e2353afb7fc2fb12efd1eb2bc5c342c792fb3b (patch)
tree4d328a1598165cf7e40363ef995b180322df168a /lib/puppet/util
parent42a539061293f8e745a9dc5b97b4415b6a275e04 (diff)
downloadpuppet-c3e2353afb7fc2fb12efd1eb2bc5c342c792fb3b.tar.gz
puppet-c3e2353afb7fc2fb12efd1eb2bc5c342c792fb3b.tar.xz
puppet-c3e2353afb7fc2fb12efd1eb2bc5c342c792fb3b.zip
Code smell: Use &&= for dependent initialization
Replaced 6 occurances of ([$@]?\w+) += +(.*) +(if +\1|unless +\1.nil\?)$ with \1 &&= \2 3 Examples: The code: end becomes: end The code: becomes: The code: res becomes: res
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/rdoc/generators/puppet_generator.rb2
-rw-r--r--lib/puppet/util/settings.rb6
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index 614c8ccec..a956241a0 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -873,7 +873,7 @@ module Generators
def find_symbol(symbol, method=nil)
res = @context.parent.find_symbol(symbol, method)
- res = res.viewer if res
+ res &&= res.viewer
res
end
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 7c70dfa8f..80cab1976 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -137,7 +137,7 @@ class Puppet::Util::Settings
# Handle a command-line argument.
def handlearg(opt, value = nil)
@cache.clear
- value = munge_value(value) if value
+ value &&= munge_value(value)
str = opt.sub(/^--/,'')
bool = true
@@ -658,7 +658,7 @@ if @config.include?(:run_mode)
def uninterpolated_value(param, environment = nil)
param = param.to_sym
- environment = environment.to_sym if environment
+ environment &&= environment.to_sym
# See if we can find it within our searchable list of values
val = catch :foundval do
@@ -682,7 +682,7 @@ if @config.include?(:run_mode)
# in which to search before the other configuration sections.
def value(param, environment = nil)
param = param.to_sym
- environment = environment.to_sym if environment
+ environment &&= environment.to_sym
# Short circuit to nil for undefined parameters.
return nil unless @config.include?(param)