Sha256: 96c8dda768c5287886bd3d7fedad956091ca229dcb6de6450c20b59a6e26c3b8

Contents?: true

Size: 469 Bytes

Versions: 2

Compression:

Stored size: 469 Bytes

Contents

class Hash
  def symbolize_keys!
    keys.each do |key|
      self[(key.to_sym rescue key) || key] = delete(key)
    end
    self
  end
  
  def recursive_symbolize_keys!
    symbolize_keys!
    # symbolize each hash in .values
    values.each{|h| h.recursive_symbolize_keys! if h.is_a?(Hash) }
    # symbolize each hash inside an array in .values
    values.select{|v| v.is_a?(Array) }.flatten.each{|h| h.recursive_symbolize_keys! if h.is_a?(Hash) }
    self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-payload-0.4.0 spec/spec_utils.rb
capistrano-payload-0.3.0 spec/spec_utils.rb