class Dynamicloud::API::Criteria::ExistsCondition
End of BetweenCondition
class
Public Class Methods
new(model_id, aliass, not_exists)
click to toggle source
Builds an instance with a specific model an alias
@param model_id Model
ID @param aliass alias to this model
# File lib/dynamic_criteria.rb, line 163 def initialize(model_id, aliass, not_exists) @model_id = model_id @aliass = aliass @not_exists = not_exists @conditions = [] @joins = [] end
Public Instance Methods
add(condition)
click to toggle source
This method will add a new condition to this ExistsCondition
.
*
@param condition new condition to a list of conditions to use @return this instance of ExistsCondition
# File lib/dynamic_criteria.rb, line 175 def add(condition) @conditions.push(condition) self end
join(join)
click to toggle source
Add a join to the list of joins
@param join join clause @return this instance of ExistsCondition
# File lib/dynamic_criteria.rb, line 184 def join(join) @joins.push(join) self end
set_alias(aliass)
click to toggle source
Sets the related alias to the model
@param aliass related alias to the model
# File lib/dynamic_criteria.rb, line 192 def set_alias(aliass) @alias = aliass end
set_model(model_id)
click to toggle source
Sets the related model to this exists condition. With this model, you can
@param model_id related model
# File lib/dynamic_criteria.rb, line 200 def set_model(model_id) @model_id = model_id end
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 208 def to_record_string(parent) built = (@not_exists ? "\"$nexists\"" : "\"$exists\"") + ': { ' + Dynamicloud::API::DynamicloudHelper.build_join_tag(@joins) + ', ' + (@model_id.nil? ? '' : ("\"model\": " + @model_id.to_s + ', ')) + (@aliass.nil? ? '' : ("\"alias\": \"" + @aliass + "\", ")) + "\"where\": {" if @conditions.length > 0 global = @conditions[0] if @conditions.length > 1 @conditions = @conditions[1..@conditions.length] @conditions.each do |condition| global = Dynamicloud::API::Criteria::ANDCondition.new global, condition end end built = built + global.to_record_string(Dynamicloud::API::Criteria::Condition::ROOT) end built + '}}' end