Sha256: f4c80c2fc9179d34d3f1c210ea0cbf20a44e7d13fd7e174e0c68a86e56ffe628
Contents?: true
Size: 993 Bytes
Versions: 1
Compression:
Stored size: 993 Bytes
Contents
require 'active_support/hash_with_indifferent_access' require 'cgi' module EZPaypal module Helper # Helper method to convert query string to hash # also convert hash to encoded hash # @param [String / Hash] object to be converted or encoded # @return [Hash] converted string or encoded hash def self.ConvertParamToHash (object) hash_obj = HashWithIndifferentAccess.new() if (object.class.to_s == "String") object.split("&").each do |e| key = CGI::unescape(e.split("=")[0]) value = CGI::unescape(e.split("=")[1]) hash_obj.merge!(key => value) end else object.each do |key, value| key = CGI::unescape(key) value = CGI::unescape(value) hash_obj.merge!(key.upcase => value) end end return hash_obj end def self.ConvertHashToQueryString (hash) hash.map { |k, v| CGI::escape(k.to_s)+"="+CGI::escape(v.to_s) }.join("&") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ez_paypal-1.0.0 | lib/core/helper.rb |