Module: CouchObject::Utils
- Defined in:
- lib/couch_object/utils.rb
Class Method Summary collapse
- .decode_strings(input) ⇒ Object
- .encode_querystring_parameter(parameter) ⇒ Object
- .join_url(*paths) ⇒ Object
Class Method Details
.decode_strings(input) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/couch_object/utils.rb', line 23 def self.decode_strings(input) case input.class.to_s when "String" # HTMLEntities.decode_entities(input).toutf8 input.toutf8 when "Array" input.map! do |n| decode_strings(n) end when "Hash" input.each_pair do |key, value| input[key] = decode_strings(value) end else input end end |
.encode_querystring_parameter(parameter) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/couch_object/utils.rb', line 13 def self.encode_querystring_parameter(parameter) case parameter.class.to_s when "Array" # [12123,"ASD"] => [%2212123%22,%22ASD%22] "[#{(parameter.map {|p| self.fix_parameter(p) }).join(",")}]" else self.fix_parameter(parameter) end end |
.join_url(*paths) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/couch_object/utils.rb', line 3 def self.join_url(*paths) if paths.any?{ |path| /:\/\// =~ path } URI.join(*paths).to_s else paths.map do |path| path.gsub(/[\/]+$/, "").gsub(/^[\/]+/, "") end.join("/") end end |