summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-05-17 14:54:09 -0700
committerTim Smith <tsmith@chef.io>2018-05-17 14:54:09 -0700
commite4f7e07c00531a73af209fb4b1a5e9c3e0a9c409 (patch)
treecc857325391dcaafd21b3dcd3a607f6a7613a7a1
parentebc86a036460d1e2f95b6a9e78153914a8be6ab1 (diff)
downloadohai-e4f7e07c00531a73af209fb4b1a5e9c3e0a9c409.tar.gz
Fix yard warnings in Mash class
Some unrecognized options and defaults that yard handles automatically Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/mash.rb53
1 files changed, 21 insertions, 32 deletions
diff --git a/lib/ohai/mash.rb b/lib/ohai/mash.rb
index 5ea21d76..f6c25db5 100644
--- a/lib/ohai/mash.rb
+++ b/lib/ohai/mash.rb
@@ -50,12 +50,9 @@
# params[:key] instead of params['key'].
class Mash < Hash
- # @param constructor<Object>
- # The default value for the mash. Defaults to an empty hash.
- #
- # @details [Alternatives]
- # If constructor is a Hash, a new mash will be created based on the keys of
- # the hash and no default value will be set.
+ # @param constructor [Object] The default value for the mash.
+ # If constructor is a Hash, a new mash will be created based on the keys of the hash and
+ # no default value will be set.
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
@@ -65,11 +62,9 @@ class Mash < Hash
end
end
- # @param key<Object> The default value for the mash. Defaults to nil.
- #
- # @details [Alternatives]
- # If key is a Symbol and it is a key in the mash, then the default value will
- # be set to the value matching the key.
+ # @param key [Object] The default value for the mash.
+ # If key is a Symbol and it is a key in the mash, then the default value will be set to
+ # the value matching the key.
def default(key = nil)
if key.is_a?(Symbol) && include?(key = key.to_s)
self[key]
@@ -81,9 +76,8 @@ class Mash < Hash
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
alias_method :regular_update, :update unless method_defined?(:regular_update)
- # @param key<Object> The key to set.
- # @param value<Object>
- # The value to set the key to.
+ # @param key [Object] The key to set.
+ # @param value [Object] The value to set the key to.
#
# @see Mash#convert_key
# @see Mash#convert_value
@@ -91,7 +85,7 @@ class Mash < Hash
regular_writer(convert_key(key), convert_value(value))
end
- # @param other_hash<Hash>
+ # @param other_hash [Hash]
# A hash to update values in the mash with. The keys and the values will be
# converted to Mash format.
#
@@ -103,7 +97,7 @@ class Mash < Hash
alias_method :merge!, :update
- # @param key<Object> The key to check for. This will be run through convert_key.
+ # @param key [Object] The key to check for. This will be run through convert_key.
#
# @return [Boolean] True if the key exists in the mash.
def key?(key)
@@ -115,36 +109,34 @@ class Mash < Hash
alias_method :has_key?, :key?
alias_method :member?, :key?
- # @param key<Object> The key to fetch. This will be run through convert_key.
- # @param *extras<Array> Default value.
+ # @param key [Object] The key to fetch. This will be run through convert_key.
+ # @param extras [Array] Default value.
#
# @return [Object] The value at key or the default value.
def fetch(key, *extras)
super(convert_key(key), *extras)
end
- # @param *indices<Array>
- # The keys to retrieve values for. These will be run through +convert_key+.
+ # @param indices [Array] The keys to retrieve values for. These will be run through +convert_key+.
#
# @return [Array] The values at each of the provided keys
def values_at(*indices)
indices.collect { |key| self[convert_key(key)] }
end
- # @param hash<Hash> The hash to merge with the mash.
+ # @param hash [Hash] The hash to merge with the mash.
#
# @return [Mash] A new mash with the hash values merged in.
def merge(hash)
dup.update(hash)
end
- # @param key<Object>
- # The key to delete from the mash.\
+ # @param key [Object] The key to delete from the mash.
def delete(key)
super(convert_key(key))
end
- # @param *rejected<Array[(String, Symbol)] The mash keys to exclude.
+ # @param keys [Array<String, Symbol>] The mash keys to exclude.
#
# @return [Mash] A new mash without the selected keys.
#
@@ -172,8 +164,8 @@ class Mash < Hash
Hash.new(default).merge(self)
end
- # @return [Mash] Convert a Hash into a Mash
- # The input Hash's default value is maintained
+ # Convert a Hash into a Mash. The input Hash's default value is maintained
+ # @return [Mash]
def self.from_hash(hash)
mash = Mash.new(hash)
mash.default = hash.default
@@ -182,18 +174,15 @@ class Mash < Hash
protected
- # @param key<Object> The key to convert.
- #
- # @param [Object]
- # The converted key. If the key was a symbol, it will be converted to a
- # string.
+ # @param key [Object] The key to convert.
+ # @return [Object] The converted key. If the key was a symbol, it will be converted to a string.
#
# @api private
def convert_key(key)
key.kind_of?(Symbol) ? key.to_s : key
end
- # @param value<Object> The value to convert.
+ # @param value [Object] The value to convert.
#
# @return [Object]
# The converted value. A Hash or an Array of hashes, will be converted to