Class: Dynamicloud::API::Criteria::INCondition
- Defined in:
- lib/dynamic_criteria.rb
Overview
This class represents an IN and NOT IN condition.
Constant Summary
Constants inherited from Condition
Condition::ROOT, Condition::WITHOUT
Instance Method Summary collapse
-
#initialize(left, values, not_in = false) ⇒ INCondition
constructor
Constructor to build either IN or NOT IN condition.
-
#to_record_string(parent) ⇒ Object
This method will return a String of this condition.
Constructor Details
#initialize(left, values, not_in = false) ⇒ INCondition
Constructor to build either IN or NOT IN condition
258 259 260 261 262 |
# File 'lib/dynamic_criteria.rb', line 258 def initialize(left, values, not_in = false) @left = left @values = values @not_in = not_in end |
Instance Method Details
#to_record_string(parent) ⇒ Object
This method will return a String of this condition
267 268 269 270 271 272 273 274 275 276 |
# File 'lib/dynamic_criteria.rb', line 267 def to_record_string(parent) condition = '"' + @left + '": {' + (@not_in ? '"$nin"' : '"$in"') + ': [' items = '' @values.each do |value| items = items + ((items.length == 0 ? '' : ',') + (value.is_a?(String) ? '"' : '') + value.to_s + (value.is_a?(String) ? '"' : '')) end condition + items + ']}' end |