Module: VTiger::Query
- Defined in:
- lib/v_tiger/query.rb
Instance Method Summary collapse
- #build_query(objectType, options = {}) ⇒ Object
- #get_more ⇒ Object
- #more_results_needed? ⇒ Boolean
- #query_string(options = {}) ⇒ Object
Instance Method Details
#build_query(objectType, options = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/v_tiger/query.rb', line 3 def build_query(objectType, = {}) @objectType = objectType @options = @query = get('query', :query => query_string) @query['result'] += get_more while more_results_needed? @query end |
#get_more ⇒ Object
26 27 28 29 30 |
# File 'lib/v_tiger/query.rb', line 26 def get_more offset = @query['result'].count new_limit = @options[:limit] - offset get('query', :query => query_string(:limit => "#{offset}, #{new_limit}"))['result'] end |
#more_results_needed? ⇒ Boolean
22 23 24 |
# File 'lib/v_tiger/query.rb', line 22 def more_results_needed? @options[:limit].present? && @query['result'].count < @options[:limit] end |
#query_string(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/v_tiger/query.rb', line 11 def query_string( = {}) limit = [:limit] || @options[:limit] [].tap do |query| query << 'select' query << '*' query << "from #{@objectType}" query << "limit #{limit}" if limit query << ';' end.join(' ') end |