class Dynamicloud::API::Criteria::Conditions

This is a builder to create conditions: AND, OR, LIKE, NOT LIKE, IN, NOT IN, EQUALS, GREATER THAN, GREATER EQUALS THAN LESSER THAN, LESSER EQUALS THAN. @author Eleazar Gomez @version 1.0.0 @since 8/22/15

Public Class Methods

and(left, right) click to toggle source

It will build an and condition using two parts (Left and Right) @param left left part of and @param right right part of and @return A built condition

# File lib/dynamic_criteria.rb, line 458
def self.and(left, right)
  ANDCondition.new(left, right);
end
between(field, left, right) click to toggle source

Builds a between condition

@param field field in this condition @param left left part of the between condition @param right right part of the between condition @return a new instance of BetweenCondition

# File lib/dynamic_criteria.rb, line 477
def self.between(field, left, right)
  return BetweenCondition.new(field, left, right)
end
equals(left, right) click to toggle source

It will build an equals condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 535
def self.equals(left, right)
  inner_equals(left, right, Dynamicloud::API::Criteria::Condition::WITHOUT)
end
exists(model_id = nil, aliass = nil) click to toggle source

Creates a new instance of ExistsCondition

@param model_id model ID @param aliass alias to this model (optional) @return a new instance of ExistsCondition

# File lib/dynamic_criteria.rb, line 486
def self.exists(model_id = nil, aliass = nil)
  ExistsCondition.new(model_id, aliass, false)
end
greater_equals(left, right) click to toggle source

It will build a greater equals condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 552
def self.greater_equals(left, right)
  inner_equals(left, right, '>')
end
greater_than(left, right) click to toggle source

It will build a greater condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 561
def self.greater_than(left, right)
  GreaterLesser.new(left, right, '>')
end
in(left, values) click to toggle source

It will an in condition using an array of values. @param left attribute to compare @param values character values to build IN condition @return a built condition.

# File lib/dynamic_criteria.rb, line 503
def self.in(left, values)
  inner_in_condition(left, values, false)
end
inner_join(model_id, aliass, condition) click to toggle source

Builds a inner join clause.

@param model_id target model id of this join @param aliass attached alias to this target model @param Condition on condition of this join clause @return a Join Clause as a condition

# File lib/dynamic_criteria.rb, line 628
def self.inner_join(model_id, aliass, condition)
  return JoinClause.new(JoinType::INNER, model_id, aliass, condition);
end
left_join(model_id, aliass, condition) click to toggle source

Builds a left join clause.

@param model_id target model id of this join @param aliass attached alias to this target model @param Condition on condition of this join clause @return a Join Clause as a condition

# File lib/dynamic_criteria.rb, line 588
def self.left_join(model_id, aliass, condition)
  return JoinClause.new(JoinType::LEFT, model_id, aliass, condition);
end
left_outer_join(model_id, aliass, condition) click to toggle source

Builds a left outer join clause.

@param model_id target model id of this join @param aliass attached alias to this target model @param Condition on condition of this join clause @return a Join Clause as a condition

# File lib/dynamic_criteria.rb, line 598
def self.left_outer_join(model_id, aliass, condition)
  return JoinClause.new(JoinType::LEFT_OUTER, model_id, aliass, condition);
end
lesser_equals(left, right) click to toggle source

It will build a lesser equals condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 578
def self.lesser_equals(left, right)
  inner_equals(left, right, '<')
end
lesser_than(left, right) click to toggle source

It will build a lesser condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 570
def self.lesser_than(left, right)
  GreaterLesser.new(left, right, '<')
end
like(left, like) click to toggle source

It will build a like condition. @param left attribute to comapare @param like to use for like condition @return a built condition.

# File lib/dynamic_criteria.rb, line 519
def self.like(left, like)
  LikeCondition.new(left, like, false)
end
not_equals(left, right) click to toggle source

It will build a not equals condition. @param left attribute to compare @param right right part of this condition @return a built condition.

# File lib/dynamic_criteria.rb, line 543
def self.not_equals(left, right)
  inner_not_equals(left, right)
end
not_exists(model_id = nil, aliass = nil) click to toggle source

Creates a new instance of ExistsCondition

@param model_id model ID @param aliass alias to this model (optional) @return a new instance of ExistsCondition

# File lib/dynamic_criteria.rb, line 495
def self.not_exists(model_id = nil, aliass = nil)
  ExistsCondition.new(model_id, aliass, true)
end
not_in(left, values) click to toggle source

It will an in condition using an array of values. @param left attribute to compare @param values number values to build IN condition @return a built condition.

# File lib/dynamic_criteria.rb, line 511
def self.not_in(left, values)
  inner_in_condition(left, values, true)
end
not_like(left, like) click to toggle source

It will build a not like condition. @param left attribute to comapare @param like to use for like condition @return a built condition.

# File lib/dynamic_criteria.rb, line 527
def self.not_like(left, like)
  LikeCondition.new(left, like, true)
end
or(left, right) click to toggle source

It will build an or condition using two parts (Left and Right) @param left left part of or @param right right part of or @return A built condition.

# File lib/dynamic_criteria.rb, line 467
def self.or(left, right)
  ORCondition.new(left, right)
end
right_join(model_id, aliass, condition) click to toggle source

Builds a right join clause.

@param model_id target model id of this join @param aliass attached alias to this target model @param Condition on condition of this join clause @return a Join Clause as a condition

# File lib/dynamic_criteria.rb, line 608
def self.right_join(model_id, aliass, condition)
  return JoinClause.new(JoinType::RIGHT, model_id, aliass, condition);
end
right_outer_join(model_id, aliass, condition) click to toggle source

Builds a right outer join clause.

@param model_id target model id of this join @param aliass attached alias to this target model @param Condition on condition of this join clause @return a Join Clause as a condition

# File lib/dynamic_criteria.rb, line 618
def self.right_outer_join(model_id, aliass, condition)
  return JoinClause.new(JoinType::RIGHT_OUTER, model_id, aliass, condition);
end

Private Class Methods

inner_equals(left, right, greater_lesser) click to toggle source

This method will build either a equals condition. @param left value to compare @param greater_lesser indicates if greater or lesser condition must be added. @return a built condition

# File lib/dynamic_criteria.rb, line 645
def self.inner_equals(left, right, greater_lesser)
  EqualCondition.new(left, right, greater_lesser)
end
inner_in_condition(left, values, not_in) click to toggle source

It will either an in or not in condition using an array of values and a boolean that indicates what kind of IN will be built. @param left attribute to compare @param values values to build IN condition @return a built condition.

# File lib/dynamic_criteria.rb, line 654
def self.inner_in_condition(left, values, not_in)
  INCondition.new(left, values, not_in)
end
inner_not_equals(left, right) click to toggle source

This method will build a not equals condition. @param left value to compare @param right right part of this condition @return a built condition

# File lib/dynamic_criteria.rb, line 637
def self.inner_not_equals(left, right)
  NotEqualCondition.new(left, right)
end