Module: Hashie::Extensions::StringifyKeys

### Home Classes Methods

### In Files

- lib/hashie/extensions/key_conversion.rb

### Methods

- #stringify_keys
- #stringify_keys!
- #stringify_keys_recursively!

### Class/Module Index

Quicksearch

- Hashie
- Hashie::Clash
- Hashie::Clash::ChainError
- Hashie::Dash
- Hashie::Extensions
- Hashie::Extensions::Coercion
- Hashie::Extensions::Coercion::ClassMethods
- Hashie::Extensions::Coercion::InstanceMethods
- Hashie::Extensions::DeepFetch
- Hashie::Extensions::DeepFetch::UndefinedPathError
- Hashie::Extensions::DeepMerge
- Hashie::Extensions::IgnoreUndeclared
- Hashie::Extensions::IndifferentAccess
- Hashie::Extensions::KeyConversion
- Hashie::Extensions::MergeInitializer
- Hashie::Extensions::MethodAccess
- Hashie::Extensions::MethodQuery
- Hashie::Extensions::MethodReader
- Hashie::Extensions::MethodWriter
- Hashie::Extensions::StringifyKeys
- Hashie::Extensions::SymbolizeKeys
- Hashie::Hash
- Hashie::HashExtensions
- Hashie::Mash
- Hashie::PrettyInspect
- Hashie::Rash
- Hashie::Trash

No matching classes.

# Hashie::Extensions::StringifyKeys

### Public Instance Methods

stringify_keys() click to toggle source

Return a new hash with all keys converted to strings.

    # File lib/hashie/extensions/key_conversion.rb, line 20
    def stringify_keys
      dup.stringify_keys!
    end

stringify_keys!() click to toggle source

Convert all keys in the hash to strings.

@example

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

    # File lib/hashie/extensions/key_conversion.rb, line 10
    def stringify_keys!
      keys.each do |k|
        stringify_keys_recursively!(self[k])
        self[k.to_s] = delete(k)
      end
      self
    end

### Protected Instance Methods

stringify_keys_recursively!(object) click to toggle source

Stringify all keys recursively within nested hashes and arrays.

    # File lib/hashie/extensions/key_conversion.rb, line 28
    def stringify_keys_recursively!(object)
      if self.class === object
        object.stringify_keys!
      elsif ::Array === object
        object.each do |i|
          stringify_keys_recursively!(i)
        end
        object
      elsif object.respond_to?(:stringify_keys!)
        object.stringify_keys!
      else
        object
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.