Method: Cloudant::QueryBuilder#build_query_string

Defined in:
lib/cloudant/query_builder.rb

#build_query_string(opts, type) ⇒ Object

TODO: Add a check to determine if options value is valid for key. ex: true is valid, 6 is not.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cloudant/query_builder.rb', line 5

def build_query_string(opts,type)
  query_str = ""
  fields    = get_fields(type)

  fields.each do |field|
    val = opts[field].to_s

    current = "#{field}=#{val}" if val != ""
    query_str << "&" << current if (query_str != "" && current)
    query_str << "?" << current if (query_str == "" && current)
  end

  query_str
end