Class | DataMapper::Mash |
In: |
lib/dm-core/support/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’].
[]= | -> | regular_writer |
Initializes a new mash.
@param [Hash, Object] constructor
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.
Sets the value associated with the specified key.
@param [Object] key The key to set. @param [Object] value The value to set the key to.
@param [Object] key 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 [Object] value 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
Gets the default value for the mash.
@param [Object] key
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.
Removes the specified keys from the mash.
@param [Array] *keys The mash keys to exclude.
@return [Hash] hash
@example
mash = { :one => 1, :two => 2, :three => 3 } mash.except!(:one, :two) mash # => { :three => 3 }
Determines whether the mash contains the specified key.
@param [Object] key The key to check for. @return [Boolean] True if the key exists in the mash.
Updates the mash with the key/value pairs from the specified hash.
@param [Hash] other_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.