Class: Squake::Util

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/squake/util.rb

Class Method Summary collapse

Class Method Details

.encode_parameters(params) ⇒ Object



13
14
15
16
17
# File 'lib/squake/util.rb', line 13

def self.encode_parameters(params)
  params.map do |k, v|
    "#{url_encode(k.to_s)}=#{url_encode(v.to_s)}" unless v.nil?
  end.join('&')
end

.url_encode(key) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/squake/util.rb', line 23

def self.url_encode(key)
  CGI.escape(key.to_s).
    # Don't use strict form encoding by changing the square bracket control
    # characters back to their literals. This is fine by the server, and
    # makes these parameter strings easier to read.
    gsub('%5B', '[').gsub('%5D', ']')
end