Module: Cloudant::QueryBuilder
- Included in:
- API
- Defined in:
- lib/cloudant/query_builder.rb
Instance Method Summary collapse
-
#build_query_string(opts, type) ⇒ Object
TODO: Add a check to determine if options value is valid for key.
-
#get_fields(type) ⇒ Object
TODO: This will be expanded to calls other than /_view.
Instance Method Details
#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 19 |
# File 'lib/cloudant/query_builder.rb', line 5 def build_query_string(opts,type) query_str = "" fields = get_fields(type) fields.each do |field| key = field val = opts[field].to_s current = "#{key}=#{val}" if val != "" query_str << "&" << current if (query_str != "" && current) query_str << "?" << current if (query_str == "" && current) end query_str end |
#get_fields(type) ⇒ Object
TODO: This will be expanded to calls other than /_view.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cloudant/query_builder.rb', line 22 def get_fields(type) case type when "view" return [:reduce,:include_docs,:descending,:endkey,:endkey_docid,:group,:group_level,:inclusive_end,:key,:keys,:limit,:skip,:stale,:startkey,:startkey_docid] when "all_docs" return [:include_docs,:descending,:endkey,:conflicts,:inclusive_end,:key,:limit,:skip,:startkey,:keys] when "changes" return [:include_docs,:descending,:feed,:filter,:heartbeat,:conflicts,:limit,:since,:style,:timeout,:doc_ids] when "doc" return [:local_seq,:attachments,:att_encoding_info,:atts_since,:conflicts,:deleted_conflicts,:latest,:meta,:open_revs,:rev,:revs,:revs_info] end end |