class Believer::OrderBy
Encapsulates the CQL ORDER BY clause
Attributes
dir[R]
field[R]
Public Class Methods
new(field, dir = :asc)
click to toggle source
@param field [Symbol] the field to order by @param dir [Symbol] the order direction. Can be :asc or :desc. Default is :asc
# File lib/believer/order_by.rb, line 10 def initialize(field, dir = :asc) raise "Invalid field: #{field}" unless field.is_a?(Symbol) || field.is_a?(String) raise "Direction must be one of (:asc|:desc): #{dir}" unless dir == :asc || dir == :desc @field = field @dir = dir end
Public Instance Methods
inverse()
click to toggle source
Inverts the direction of the order
# File lib/believer/order_by.rb, line 23 def inverse OrderBy.new(@field, @dir == :asc ? :desc : :asc) end
to_cql()
click to toggle source
Creates the CQL ORDER BY clause
# File lib/believer/order_by.rb, line 18 def to_cql "ORDER BY #{@field} #{@dir.to_s.upcase}" end