Sha256: ee8a6568119b7a0ac0ae7a12bd5da6989ae74611ba8955e9f1e60b537f2e3323

Contents?: true

Size: 442 Bytes

Versions: 3

Compression:

Stored size: 442 Bytes

Contents

module Upstart
  class Exporter
    class HashUtils

      def self.symbolize_keys(obj)
        case obj
          when Hash
            Hash[
              obj.map do |key, value|
                [key.respond_to?(:to_sym) ? key.to_sym : key, symbolize_keys(value)]
              end
            ]
          when Array
            obj.map {|value| symbolize_keys(value)}
          else
            obj
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
upstart-exporter-2.1.5 lib/upstart-exporter/hash_utils.rb
upstart-exporter-2.1.4 lib/upstart-exporter/hash_utils.rb
upstart-exporter-2.1.3 lib/upstart-exporter/hash_utils.rb