Class: Udb::ExceptionCode

Inherits:
TopLevelDatabaseObject show all
Extended by:
T::Sig
Includes:
Comparable, Code
Defined in:
lib/udb/obj/exception_code.rb

Overview

a synchroncous exception code

Instance Attribute Summary

Attributes inherited from DatabaseObject

#arch, #data, #data_path, #long_name, #name

Instance Method Summary collapse

Methods included from Code

#display_name, #num, #var

Methods inherited from TopLevelDatabaseObject

create_json_schemer_resolver, #initialize, #key?, #keys

Methods inherited from DatabaseObject

#__source, #cfg_arch, #cfg_arch?, #clone, #defer, #defined_by_condition, #description, #initialize, #inspect, #kind, #source_line

Constructor Details

This class inherits a constructor from Udb::TopLevelDatabaseObject

Instance Method Details

#<=>(other) ⇒ Object



49
50
51
52
53
# File 'lib/udb/obj/exception_code.rb', line 49

def <=>(other)
  return nil unless T.cast(other, Object).is_a?(ExceptionCode)

  num <=> T.cast(other, ExceptionCode).num
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/udb/obj/exception_code.rb', line 56

def eql?(other)
  (self <=> other) == 0
end

#hashObject



61
# File 'lib/udb/obj/exception_code.rb', line 61

def hash = [ExceptionCode, num].hash

#validate(resolver) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/udb/obj/exception_code.rb', line 36

def validate(resolver)
  super(resolver)

  @arch.exception_codes.each do |code|
    next if code == self

    if num == code.num
      raise ValidationError, "Duplicate exception code #{num} for #{name}, #{code.name}"
    end
  end
end