Class: Dynamicloud::API::Criteria::Conditions

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

Overview

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

Since:

  • 8/22/15

Version:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.and(left, right) ⇒ Object

It will build an and condition using two parts (Left and Right)

Parameters:

  • left

    left part of and

  • right

    right part of and

Returns:

  • A built condition

Since:

  • 8/22/15



458
459
460
# File 'lib/dynamic_criteria.rb', line 458

def self.and(left, right)
  ANDCondition.new(left, right);
end

.between(field, left, right) ⇒ Object

Builds a between condition

Parameters:

  • field

    field in this condition

  • left

    left part of the between condition

  • right

    right part of the between condition

Returns:

  • a new instance of BetweenCondition

Since:

  • 8/22/15



477
478
479
# File 'lib/dynamic_criteria.rb', line 477

def self.between(field, left, right)
  return BetweenCondition.new(field, left, right)
end

.equals(left, right) ⇒ Object

It will build an equals condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



535
536
537
# 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) ⇒ Object

Creates a new instance of ExistsCondition

Parameters:

  • model_id (defaults to: nil)

    model ID

  • aliass (defaults to: nil)

    alias to this model (optional)

Returns:

  • a new instance of ExistsCondition

Since:

  • 8/22/15



486
487
488
# 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) ⇒ Object

It will build a greater equals condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



552
553
554
# File 'lib/dynamic_criteria.rb', line 552

def self.greater_equals(left, right)
  inner_equals(left, right, '>')
end

.greater_than(left, right) ⇒ Object

It will build a greater condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



561
562
563
# File 'lib/dynamic_criteria.rb', line 561

def self.greater_than(left, right)
  GreaterLesser.new(left, right, '>')
end

.in(left, values) ⇒ Object

It will an in condition using an array of values.

Parameters:

  • left

    attribute to compare

  • values

    character values to build IN condition

Returns:

  • a built condition.

Since:

  • 8/22/15



503
504
505
# 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) ⇒ Object

Builds a inner join clause.

Parameters:

  • model_id

    target model id of this join

  • aliass

    attached alias to this target model

  • Condition

    on condition of this join clause

Returns:

  • a Join Clause as a condition

Since:

  • 8/22/15



628
629
630
# 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) ⇒ Object

Builds a left join clause.

Parameters:

  • model_id

    target model id of this join

  • aliass

    attached alias to this target model

  • Condition

    on condition of this join clause

Returns:

  • a Join Clause as a condition

Since:

  • 8/22/15



588
589
590
# 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) ⇒ Object

Builds a left outer join clause.

Parameters:

  • model_id

    target model id of this join

  • aliass

    attached alias to this target model

  • Condition

    on condition of this join clause

Returns:

  • a Join Clause as a condition

Since:

  • 8/22/15



598
599
600
# 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) ⇒ Object

It will build a lesser equals condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



578
579
580
# File 'lib/dynamic_criteria.rb', line 578

def self.lesser_equals(left, right)
  inner_equals(left, right, '<')
end

.lesser_than(left, right) ⇒ Object

It will build a lesser condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



570
571
572
# File 'lib/dynamic_criteria.rb', line 570

def self.lesser_than(left, right)
  GreaterLesser.new(left, right, '<')
end

.like(left, like) ⇒ Object

It will build a like condition.

Parameters:

  • left

    attribute to comapare

  • like

    to use for like condition

Returns:

  • a built condition.

Since:

  • 8/22/15



519
520
521
# File 'lib/dynamic_criteria.rb', line 519

def self.like(left, like)
  LikeCondition.new(left, like, false)
end

.not_equals(left, right) ⇒ Object

It will build a not equals condition.

Parameters:

  • left

    attribute to compare

  • right

    right part of this condition

Returns:

  • a built condition.

Since:

  • 8/22/15



543
544
545
# 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) ⇒ Object

Creates a new instance of ExistsCondition

Parameters:

  • model_id (defaults to: nil)

    model ID

  • aliass (defaults to: nil)

    alias to this model (optional)

Returns:

  • a new instance of ExistsCondition

Since:

  • 8/22/15



495
496
497
# 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) ⇒ Object

It will an in condition using an array of values.

Parameters:

  • left

    attribute to compare

  • values

    number values to build IN condition

Returns:

  • a built condition.

Since:

  • 8/22/15



511
512
513
# File 'lib/dynamic_criteria.rb', line 511

def self.not_in(left, values)
  inner_in_condition(left, values, true)
end

.not_like(left, like) ⇒ Object

It will build a not like condition.

Parameters:

  • left

    attribute to comapare

  • like

    to use for like condition

Returns:

  • a built condition.

Since:

  • 8/22/15



527
528
529
# File 'lib/dynamic_criteria.rb', line 527

def self.not_like(left, like)
  LikeCondition.new(left, like, true)
end

.or(left, right) ⇒ Object

It will build an or condition using two parts (Left and Right)

Parameters:

  • left

    left part of or

  • right

    right part of or

Returns:

  • A built condition.

Since:

  • 8/22/15



467
468
469
# File 'lib/dynamic_criteria.rb', line 467

def self.or(left, right)
  ORCondition.new(left, right)
end

.right_join(model_id, aliass, condition) ⇒ Object

Builds a right join clause.

Parameters:

  • model_id

    target model id of this join

  • aliass

    attached alias to this target model

  • Condition

    on condition of this join clause

Returns:

  • a Join Clause as a condition

Since:

  • 8/22/15



608
609
610
# 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) ⇒ Object

Builds a right outer join clause.

Parameters:

  • model_id

    target model id of this join

  • aliass

    attached alias to this target model

  • Condition

    on condition of this join clause

Returns:

  • a Join Clause as a condition

Since:

  • 8/22/15



618
619
620
# 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