Class: Dynamicloud::API::Criteria::OrderByClause

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

Overview

This class represents an OrderBy clause

Author:

  • Eleazar Gomez

Since:

  • 8/23/15

Version:

  • 1.0.0

Constant Summary

Constants inherited from Condition

Condition::ROOT, Condition::WITHOUT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ascObject

Since:

  • 8/23/15



413
414
415
# File 'lib/dynamic_criteria.rb', line 413

def asc
  @asc
end

#attributeObject

Since:

  • 8/23/15



413
414
415
# File 'lib/dynamic_criteria.rb', line 413

def attribute
  @attribute
end

Class Method Details

.asc(attribute) ⇒ Object

Build an orderBy clause using asc flag

Parameters:

  • attribute

    attribute to use to order

Returns:

  • an orderBy object

Since:

  • 8/23/15



418
419
420
421
422
423
424
# File 'lib/dynamic_criteria.rb', line 418

def self.asc(attribute)
  order = OrderByClause.new
  order.asc = true
  order.attribute = attribute

  order
end

.desc(attribute) ⇒ Object

Build an orderBy clause using desc flag

Parameters:

  • attribute

    attribute to use to order

Returns:

  • an orderBy object

Since:

  • 8/23/15



429
430
431
432
433
434
435
# File 'lib/dynamic_criteria.rb', line 429

def self.desc(attribute)
  order = OrderByClause.new
  order.asc = false
  order.attribute = attribute

  order
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

Since:

  • 8/23/15



440
441
442
# File 'lib/dynamic_criteria.rb', line 440

def to_record_string(parent)
  '"order": "' + attribute + (asc ? ' ASC' : ' DESC') + '"'
end