Class: SoftFailExitStatus

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schema.rb

Overview

The exit status number that will cause this job to soft-fail

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1109
1110
1111
1112
1113
1114
# File 'lib/schema.rb', line 1109

def self.from_dynamic!(d)
  return new(enum: d, integer: nil) if schema[:enum].right.valid? d
  return new(integer: d, enum: nil) if schema[:integer].right.valid? d

  raise "Invalid union"
end

.from_json!(json) ⇒ Object



1116
1117
1118
# File 'lib/schema.rb', line 1116

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1120
1121
1122
1123
1124
1125
1126
# File 'lib/schema.rb', line 1120

def to_dynamic
  if !enum.nil?
    enum
  elsif !integer.nil?
    integer
  end
end

#to_json(options = nil) ⇒ Object



1128
1129
1130
# File 'lib/schema.rb', line 1128

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end