Class: QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rally_rest_api/query.rb

Overview

Internal support for generating query string for the Rally Webservice. See RestQuery for examples.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operator, &block) ⇒ QueryBuilder

Returns a new instance of QueryBuilder.



164
165
166
167
# File 'lib/rally_rest_api/query.rb', line 164

def initialize(operator, &block)
  @operator = operator
  instance_eval(&block)
end

Instance Attribute Details

#operatorObject (readonly)

:nodoc: all



139
140
141
# File 'lib/rally_rest_api/query.rb', line 139

def operator
  @operator
end

Instance Method Details

#_and_(&block) ⇒ Object



169
170
171
# File 'lib/rally_rest_api/query.rb', line 169

def _and_(&block)
  add(QueryBuilder.new("and", &block), @operator)
end

#_or_(&block) ⇒ Object



173
174
175
# File 'lib/rally_rest_api/query.rb', line 173

def _or_(&block)
  add(QueryBuilder.new("or", &block), @operator)
end

#add(new_value, op) ⇒ Object



177
178
179
180
181
182
183
184
# File 'lib/rally_rest_api/query.rb', line 177

def add(new_value, op)
  if value.empty?
    value.push new_value
  else  
    value.push QueryString.new(value.pop, op, new_value)  
  end
  self
end

#to_qObject



190
191
192
# File 'lib/rally_rest_api/query.rb', line 190

def to_q
  value[0].to_q
end

#valueObject



186
187
188
# File 'lib/rally_rest_api/query.rb', line 186

def value
  @value ||= []
end