Class: SchemaNotify

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

Overview

Array of notification options for this step

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



214
215
216
217
218
219
220
221
222
223
# File 'lib/schema.rb', line 214

def self.from_dynamic!(d)
  begin
    value = BuildNotify1.from_dynamic!(d)
    return new(build_notify1: value, enum: nil) if schema[:build_notify1].right.valid? value
  rescue StandardError
  end
  return new(enum: d, build_notify1: nil) if schema[:enum].right.valid? d

  raise "Invalid union"
end

.from_json!(json) ⇒ Object



225
226
227
# File 'lib/schema.rb', line 225

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

Instance Method Details

#to_dynamicObject



229
230
231
232
233
234
235
# File 'lib/schema.rb', line 229

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

#to_json(options = nil) ⇒ Object



237
238
239
# File 'lib/schema.rb', line 237

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