Class: Dynamicloud::API::Criteria::ORCondition
- Defined in:
- lib/dynamic_criteria.rb
Overview
This class represents an or condition. Implements condition to return a JSON according left and right parts.
Constant Summary
Constants inherited from Condition
Condition::ROOT, Condition::WITHOUT
Instance Method Summary collapse
-
#initialize(left, right) ⇒ ORCondition
constructor
Constructor tha builds this condition.
-
#to_record_string(parent) ⇒ Object
This method will return a String of this condition.
Constructor Details
#initialize(left, right) ⇒ ORCondition
Constructor tha builds this condition
361 362 363 364 365 366 367 368 |
# File 'lib/dynamic_criteria.rb', line 361 def initialize(left, right) unless (left.is_a?(Condition)) || (right.is_a?(Condition)) raise 'left and right should implement Condition' end @left = left @right = right end |
Instance Method Details
#to_record_string(parent) ⇒ Object
This method will return a String of this condition
373 374 375 376 |
# File 'lib/dynamic_criteria.rb', line 373 def to_record_string(parent) (parent.is_a?(ORCondition) ? '' : '"$or": {') + @left.to_record_string(self) + ',' + @right.to_record_string(self) + (parent.is_a?(ORCondition) ? '' : '}') end |