Class | SymbolHash
In: | lib/yard/core_ext/symbol_hash.rb
Parent: | Hash

A subclass of Hash where all keys are converted into Symbols, and optionally, all String values are converted into Symbols.

### Methods

[] [] []= delete has_key? merge merge! new update

### Public Class methods

[](*hsh)

@overload [](hash)

      Creates a SymbolHash object from an existing Hash

      @example
        SymbolHash['x' => 1, :y => 2] # => #<SymbolHash:0x...>
      @param [Hash] hash the hash object
      @return [SymbolHash] a new SymbolHash from a hash object

@overload [](*list)

      Creates a SymbolHash from an even list of keys and values

      @example
        SymbolHash[key1, value1, key2, value2, ...]
      @param [Array] list an even list of key followed by value
      @return [SymbolHash] a new SymbolHash object

new(symbolize_value = true)

Creates a new SymbolHash object

@param [Boolean] symbolize_value converts any String values into Symbols

      if this is set to +true+.

### Public Instance methods

[](key)

Accessed a symbolized key @param [to_sym] key the key to access @return [Object] the value associated with the key

[]=(key, value)

Assigns a value to a symbolized key @param [to_sym] key the key @param [Object] value the value to be assigned. If this is a String and

      values are set to be symbolized, it will be converted into a Symbol.

delete(key)

Deleted a key and value associated with it @param [to_sym] key the key to delete @return [void]

has_key?(key)

Tests if a symbolized key exists @param [to_sym] key the key to test @return [Boolean] whether the key exists

merge(hash)

Merges the contents of another hash into a new SymbolHash object

@param [Hash] hash the hash of objects to copy @return [SymbolHash] a new SymbolHash containing the merged data

merge!(hash)

Alias for update

update(hash)

Updates the object with the contents of another Hash object. This method modifies the original SymbolHash object

@param [Hash] hash the hash object to copy the values from @return [SymbolHash] self

[Validate]