class Dynamicloud::API::Criteria::INCondition

This class represents an IN and NOT IN condition. @author Eleazar Gomez @version 1.0.0 @since 8/24/15

Public Class Methods

new(left, values, not_in = false) click to toggle source

Constructor to build either IN or NOT IN condition @param left attribute to compare @param values values to use to build IN or NOT IN condition @param not_in indicates if this condition is a not in.

# File lib/dynamic_criteria.rb, line 258
def initialize(left, values, not_in = false)
  @left = left
  @values = values
  @not_in = not_in
end

Public Instance Methods

to_record_string(parent) click to toggle source

This method will return a String of this condition @param parent this is the parent of this condition @return a json

# 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