Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/nerdz/rebinds.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_param(par) ⇒ Object



39
40
41
42
43
# File 'lib/nerdz/rebinds.rb', line 39

def self.from_param(par)
  Hash[par.split('&').map {|x| x.split('=', 2).map {|y| CGI.unescape(y) } }]
rescue
  {}
end

Instance Method Details

#to_paramObject



33
34
35
36
37
# File 'lib/nerdz/rebinds.rb', line 33

def to_param
  self.to_a.map {|kv|
    kv.map {|v| CGI.escape(v.to_s) }.join(?=)
  }.join(?&)
end