diff options
author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:06:48 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:06:48 -0700 |
commit | 42a539061293f8e745a9dc5b97b4415b6a275e04 (patch) | |
tree | fb268244b7ca95dd36e8136bcd3c02fd2a05632f /lib/puppet/transportable.rb | |
parent | a07bbe2e711ee22a40e147c046997c8813ae3cc8 (diff) | |
download | puppet-42a539061293f8e745a9dc5b97b4415b6a275e04.tar.gz puppet-42a539061293f8e745a9dc5b97b4415b6a275e04.tar.xz puppet-42a539061293f8e745a9dc5b97b4415b6a275e04.zip |
Code smell: Use ||= for conditional initialization
Replaced 55 occurances of
([$@]?\w+) += +(.*) +(if +\1.nil\?|if +! *\1|unless +\1|unless +defined\?\(\1\))$
with
\1 ||= \2
3 Examples:
The code:
@sync
becomes:
@sync
The code:
becomes:
The code:
if @yydebug
becomes:
if @yydebug
Diffstat (limited to 'lib/puppet/transportable.rb')
-rw-r--r-- | lib/puppet/transportable.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index b97817c85..74c1bbf6a 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -34,7 +34,7 @@ module Puppet end def ref - @ref = Puppet::Resource.new(@type, @name) unless defined?(@ref) + @ref ||= Puppet::Resource.new(@type, @name) @ref.to_s end @@ -239,7 +239,7 @@ module Puppet end def param(param,value) - @parameters = {} unless defined?(@parameters) + @parameters ||= {} @parameters[param] = value end |