summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/cacher.rb4
-rw-r--r--lib/puppet/util/fileparsing.rb2
-rwxr-xr-xlib/puppet/util/filetype.rb2
-rw-r--r--lib/puppet/util/inline_docs.rb2
-rw-r--r--lib/puppet/util/log/destinations.rb2
-rw-r--r--lib/puppet/util/log_paths.rb2
-rw-r--r--lib/puppet/util/rdoc/parser.rb2
-rw-r--r--lib/puppet/util/subclass_loader.rb2
8 files changed, 9 insertions, 9 deletions
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb
index 8a0acc82f..df8c28a7d 100644
--- a/lib/puppet/util/cacher.rb
+++ b/lib/puppet/util/cacher.rb
@@ -88,7 +88,7 @@ module Puppet::Util::Cacher
private
def cache_timestamp
- @cache_timestamp = Time.now unless defined?(@cache_timestamp)
+ @cache_timestamp ||= Time.now
@cache_timestamp
end
@@ -122,7 +122,7 @@ module Puppet::Util::Cacher
end
def value_cache
- @value_cache = {} unless @value_cache
+ @value_cache ||= {}
@value_cache
end
end
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index a5d7ca4ab..bc3555915 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -203,7 +203,7 @@ module Puppet::Util::FileParsing
end
def line_separator
- @line_separator = "\n" unless defined?(@line_separator)
+ @line_separator ||= "\n"
@line_separator
end
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 712895f1f..98aaf8cc1 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -72,7 +72,7 @@ class Puppet::Util::FileType
# Pick or create a filebucket to use.
def bucket
- @bucket = Puppet::Type.type(:filebucket).mkdefaultbucket.bucket unless defined?(@bucket)
+ @bucket ||= Puppet::Type.type(:filebucket).mkdefaultbucket.bucket
@bucket
end
diff --git a/lib/puppet/util/inline_docs.rb b/lib/puppet/util/inline_docs.rb
index b04b40a22..95a8c2ac0 100644
--- a/lib/puppet/util/inline_docs.rb
+++ b/lib/puppet/util/inline_docs.rb
@@ -15,7 +15,7 @@ module Puppet::Util::InlineDocs
attr_writer :doc
def doc
- @doc = "" unless @doc
+ @doc ||= ""
@doc
end
diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb
index 6c94247ea..515568c93 100644
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@ -154,7 +154,7 @@ Puppet::Util::Log.newdesttype :host do
def handle(msg)
unless msg.is_a?(String) or msg.remote
- @hostname = Facter["hostname"].value unless defined?(@hostname)
+ @hostname ||= Facter["hostname"].value
unless defined?(@domain)
@domain = Facter["domain"].value
@hostname += ".#{@domain}" if @domain
diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb
index a7ad18906..e09ceb7fa 100644
--- a/lib/puppet/util/log_paths.rb
+++ b/lib/puppet/util/log_paths.rb
@@ -5,7 +5,7 @@ module Puppet::Util::LogPaths
# return the full path to us, for logging and rollback
# some classes (e.g., FileTypeRecords) will have to override this
def path
- @path = pathbuilder unless defined?(@path)
+ @path ||= pathbuilder
"/" + @path.join("/")
end
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index c79adf671..606d06cdd 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -67,7 +67,7 @@ class Parser
names.each do |name|
prev_container = container
container = find_object_named(container, name)
- container = prev_container.add_class(PuppetClass, name, nil) unless container
+ container ||= prev_container.add_class(PuppetClass, name, nil)
end
[container, final_name]
end
diff --git a/lib/puppet/util/subclass_loader.rb b/lib/puppet/util/subclass_loader.rb
index 6f861439a..ee6b68b15 100644
--- a/lib/puppet/util/subclass_loader.rb
+++ b/lib/puppet/util/subclass_loader.rb
@@ -68,7 +68,7 @@ module Puppet::Util::SubclassLoader
# Retrieve or calculate a name.
def name(dummy_argument=:work_arround_for_ruby_GC_bug)
- @name = self.to_s.sub(/.+::/, '').intern unless defined?(@name)
+ @name ||= self.to_s.sub(/.+::/, '').intern
@name
end