class ToQuery
Attributes
hash[R]
Public Class Methods
call(hash)
click to toggle source
# File lib/ruby_branch/utils/to_query.rb, line 6 def self.call(hash) new.call(hash) end
Public Instance Methods
call(hash)
click to toggle source
# File lib/ruby_branch/utils/to_query.rb, line 10 def call(hash) @hash = hash to_query(hash) end
Private Instance Methods
to_param(key, value)
click to toggle source
# File lib/ruby_branch/utils/to_query.rb, line 27 def to_param(key, value) "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" end
to_query(hash)
click to toggle source
# File lib/ruby_branch/utils/to_query.rb, line 17 def to_query(hash) hash.collect do |key, value| if value.is_a?(Hash) to_query(value) else to_param(key, value) end end.compact.sort! * "&" end