Class: Dynamicloud::API::Criteria::ANDCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/dynamic_criteria.rb

Overview

End of JoinClause class

Constant Summary

Constants inherited from Condition

Condition::ROOT, Condition::WITHOUT

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ ANDCondition

Will build an and condition using two part.

Parameters:

  • left

    left part of this and condition

  • right

    right part of this and condition



85
86
87
88
89
90
91
92
# File 'lib/dynamic_criteria.rb', line 85

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

Parameters:

  • parent

    this is the parent of this condition

Returns:

  • a json



97
98
99
# File 'lib/dynamic_criteria.rb', line 97

def to_record_string(parent)
  (parent.is_a?(ORCondition) ? '"where": {' : '') + @left.to_record_string(self) + ',' + @right.to_record_string(self) + (parent.is_a?(ORCondition) ? '}' : '')
end