Class: QueryBuilder
- Inherits:
-
Object
- Object
- QueryBuilder
- 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
-
#operator ⇒ Object
readonly
:nodoc: all.
Instance Method Summary collapse
- #_and_(&block) ⇒ Object
- #_or_(&block) ⇒ Object
- #add(new_value, op) ⇒ Object
-
#initialize(operator, &block) ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
- #to_q ⇒ Object
- #value ⇒ Object
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
#operator ⇒ Object (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_q ⇒ Object
190 191 192 |
# File 'lib/rally_rest_api/query.rb', line 190 def to_q value[0].to_q end |
#value ⇒ Object
186 187 188 |
# File 'lib/rally_rest_api/query.rb', line 186 def value @value ||= [] end |