Sha256: db2e09cee49e47eb97977e5a4206a38c20a98ecdc6fa7c88f060d7601ad11944

Contents?: true

Size: 369 Bytes

Versions: 1

Compression:

Stored size: 369 Bytes

Contents

class Hash
  def symbolize_keys!
    self.keys.each do |k|
      if self[k].is_a? Hash
        self[k].symbolize_keys!
      end
      if k.is_a? String
        raise RuntimeError, "Symbolizing key '#{k}' means overwrite some data (key :#{k} exists)" if self[k.to_sym]
        self[k.to_sym] = self[k]
        self.delete(k)
      end
    end
    return self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ammitto-0.1.0 lib/ammitto/hash.rb