Class: MatrixClass

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

Overview

Configuration for multi-dimension Build Matrix

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1272
1273
1274
1275
1276
1277
1278
# File 'lib/schema.rb', line 1272

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    adjustments: d["adjustments"]&.map { |x| Adjustment.from_dynamic!(x) },
    setup: Setup.from_dynamic!(d.fetch("setup"))
  )
end

.from_json!(json) ⇒ Object



1280
1281
1282
# File 'lib/schema.rb', line 1280

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

Instance Method Details

#to_dynamicObject



1284
1285
1286
1287
1288
1289
# File 'lib/schema.rb', line 1284

def to_dynamic
  {
    "adjustments" => adjustments&.map(&:to_dynamic),
    "setup" => setup.to_dynamic
  }
end

#to_json(options = nil) ⇒ Object



1291
1292
1293
# File 'lib/schema.rb', line 1291

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