Sha256: 90ba1e0381724385477b35ebc871b8d74b375efeddff66b7f82cfdb552d251da

Contents?: true

Size: 513 Bytes

Versions: 3

Compression:

Stored size: 513 Bytes

Contents

module Zhima
  module Util
    def self.symbolize_hash_keys(hash)
      return hash.symbolize_keys! if hash.respond_to?(:symbolize_keys!)

      new_hash = {}
      hash.each do |key, value|
        new_hash[key.to_sym] = value
      end
      new_hash
    end

    def self.base64_and_uri_encode(str)
      URI.encode_www_form_component(Base64.strict_encode64(str))
    end

    # 暂时只做了一级hash的处理
    def self.to_query(hash)
      hash.map{ |pair| pair.join("=") }.join("&")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zhima-0.2.4 lib/zhima/util.rb
zhima-0.2.3 lib/zhima/util.rb
zhima-0.2.2 lib/zhima/util.rb