lib/better_reddit/utility/helper.rb
# Recursively traverses a Hash table to ensure keys are symbolized.
# A necessary evil to ensure data is handled correctly throughout the library processing.
Recursively traverses a Hash table to ensure keys are symbolized.
A necessary evil to ensure data is handled correctly throughout the library processing.
Recursively traverses a Hash table to ensure keys are symbolized . A necessary evil to ensure data is handled correctly throughout the library processing .
def symbolize_names(object)
        case object
        when Hash
          {}.tap do |new_hash|
            object.each do |key, value|
              key = begin
                key.to_sym
                    rescue StandardError
                      key
              end
              new_hash[key] = symbolize_names(value)
            end
          end
        when Array
          object.map { |value| symbolize_names(value) }
        else
          object
        end.freeze
      end
def symbolize_names ( object ) case object when Hash { } . tap do | new_hash | object . each do | key , value | key = begin key . to_sym rescue StandardError key end new_hash [ key ] = symbolize_names ( value ) end end when Array object . map { | value | symbolize_names ( value ) } else object end . freeze end
Recursively traverses a Hash table to ensure keys are symbolized.
Recursively traverses a Hash table to ensure keys are symbolized .
object