Class Mash
In: lib/extlib/mash.rb
Parent: Hash

This class has dubious semantics and we only have it so that people can write params[:key] instead of params[‘key’].

Methods

External Aliases

[]= -> regular_writer

Public Class methods

@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.

Public Instance methods

@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

@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 *rejected<Array[(String, Symbol)] The mash keys to exclude.

@return [Mash] A new mash without the selected keys.

@example

  { :one => 1, :two => 2, :three => 3 }.except(:one)
    #=> { "two" => 2, "three" => 3 }

@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.

@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.

@param hash<Hash> The hash to merge with the mash.

@return [Mash] A new mash with the hash values merged in.

Used to provide the same interface as Hash.

@return [Mash] This mash unchanged.

@return [Hash] The mash as a Hash with symbolized keys.

@return [Hash] The mash as a Hash with string keys.

@param other_hash<Hash>

  A hash to update values in the mash with. The keys and the values will be
  converted to Mash format.

@return [Mash] The updated mash.

@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

Protected Instance methods

@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.

@api private

@param value<Object> The value to convert.

@return [Object]

  The converted value. A Hash or an Array of hashes, will be converted to
  their Mash equivalents.

@api private

[Validate]