Class: Svix::Ordering

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/models/ordering.rb

Overview

Defines the ordering in a listing of results.

Constant Summary collapse

ASCENDING =
"ascending".freeze
DESCENDING =
"descending".freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Ordering

Returns a new instance of Ordering.



13
14
15
16
17
18
19
# File 'lib/svix/models/ordering.rb', line 13

def initialize(value)
  unless Ordering.all_vars.include?(value)
    raise "Invalid ENUM value '#{value}' for class #Ordering"
  end

  @value = value
end

Class Method Details

.all_varsObject



9
10
11
# File 'lib/svix/models/ordering.rb', line 9

def self.all_vars
  @all_vars ||= [ASCENDING, DESCENDING].freeze
end

.deserialize(value) ⇒ Object



21
22
23
24
# File 'lib/svix/models/ordering.rb', line 21

def self.deserialize(value)
  return value if Ordering.all_vars.include?(value)
  raise "Invalid ENUM value '#{value}' for class #Ordering"
end

Instance Method Details

#serializeObject



26
27
28
# File 'lib/svix/models/ordering.rb', line 26

def serialize
  @value
end