Class: Adjustment

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

Overview

An adjustment to a Build Matrix

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1204
1205
1206
1207
1208
1209
1210
1211
# File 'lib/schema.rb', line 1204

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    skip: d["skip"] ? Skip.from_dynamic!(d["skip"]) : nil,
    soft_fail: d["soft_fail"] ? SoftFail.from_dynamic!(d["soft_fail"]) : nil,
    adjustment_with: With.from_dynamic!(d.fetch("with"))
  )
end

.from_json!(json) ⇒ Object



1213
1214
1215
# File 'lib/schema.rb', line 1213

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

Instance Method Details

#to_dynamicObject



1217
1218
1219
1220
1221
1222
1223
# File 'lib/schema.rb', line 1217

def to_dynamic
  {
    "skip" => skip&.to_dynamic,
    "soft_fail" => soft_fail&.to_dynamic,
    "with" => adjustment_with.to_dynamic
  }
end

#to_json(options = nil) ⇒ Object



1225
1226
1227
# File 'lib/schema.rb', line 1225

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