Module: Hashie::Extensions::SymbolizeKeys::ClassMethods

### Home Classes Methods

### In Files

- lib/hashie/extensions/symbolize_keys.rb

### Methods

- #symbolize_keys
- #symbolize_keys!
- #symbolize_keys_recursively!

### Class/Module Index

Quicksearch

- Hashie
- Hashie::Clash
- Hashie::Clash::ChainError
- Hashie::CoercionError
- Hashie::Dash
- Hashie::Extensions
- Hashie::Extensions::Coercion
- Hashie::Extensions::Coercion::ClassMethods
- Hashie::Extensions::Coercion::InstanceMethods
- Hashie::Extensions::Dash
- Hashie::Extensions::Dash::IndifferentAccess
- Hashie::Extensions::Dash::IndifferentAccess::ClassMethods
- Hashie::Extensions::DeepFetch
- Hashie::Extensions::DeepFetch::UndefinedPathError
- Hashie::Extensions::DeepFind
- Hashie::Extensions::DeepMerge
- Hashie::Extensions::IgnoreUndeclared
- Hashie::Extensions::IndifferentAccess
- Hashie::Extensions::KeyConversion
- Hashie::Extensions::Mash
- Hashie::Extensions::Mash::SafeAssignment
- Hashie::Extensions::MergeInitializer
- Hashie::Extensions::MethodAccess
- Hashie::Extensions::MethodAccessWithOverride
- Hashie::Extensions::MethodOverridingWriter
- Hashie::Extensions::MethodQuery
- Hashie::Extensions::MethodReader
- Hashie::Extensions::MethodWriter
- Hashie::Extensions::Parsers
- Hashie::Extensions::Parsers::YamlErbParser
- Hashie::Extensions::PrettyInspect
- Hashie::Extensions::StringifyKeys
- Hashie::Extensions::StringifyKeys::ClassMethods
- Hashie::Extensions::SymbolizeKeys
- Hashie::Extensions::SymbolizeKeys::ClassMethods
- Hashie::Hash
- Hashie::Mash
- Hashie::Rash
- Hashie::Trash

No matching classes.

# Hashie::Extensions::SymbolizeKeys::ClassMethods

### Public Instance Methods

symbolize_keys(hash) click to toggle source

Return a copy of hash with all keys converted to symbols. @param [::Hash] hash

    # File lib/hashie/extensions/symbolize_keys.rb, line 56
    def symbolize_keys(hash)
      hash.dup.tap do | new_hash |
        symbolize_keys! new_hash
      end
    end

symbolize_keys!(hash) click to toggle source

Convert all keys in hash to symbols.

@param [Hash] hash @example

    test = {'abc' => 'def'}
    Hashie.symbolize_keys! test
    test # => {:abc => 'def'}

    # File lib/hashie/extensions/symbolize_keys.rb, line 45
    def symbolize_keys!(hash)
      hash.keys.each do |k|
        symbolize_keys_recursively!(hash[k])
        hash[k.to_sym] = hash.delete(k)
      end
      hash
    end

symbolize_keys_recursively!(object) click to toggle source

Symbolize all keys recursively within nested hashes and arrays. @api private

    # File lib/hashie/extensions/symbolize_keys.rb, line 25
    def symbolize_keys_recursively!(object)
      object.symbolize_keys! if object.respond_to? :symbolize_keys!

      case object
      when ::Array
        object.each do |i|
          symbolize_keys_recursively!(i)
        end
      when ::Hash
        symbolize_keys!(object)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.