Class: SecretElement

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
# File 'lib/schemas.rb', line 1471

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    environment:    d.fetch("environment"),
    is_fallback:    d["isFallback"],
    secret_comment: d.fetch("secretComment"),
    secret_key:     d.fetch("secretKey"),
    secret_path:    d["secretPath"],
    secret_value:   d.fetch("secretValue"),
    secret_type:    d.fetch("type"),
    version:        d.fetch("version"),
    workspace:      d.fetch("workspace"),
  )
end

.from_json!(json) ⇒ Object



1486
1487
1488
# File 'lib/schemas.rb', line 1486

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

Instance Method Details

#to_dynamicObject



1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
# File 'lib/schemas.rb', line 1490

def to_dynamic
  {
    "environment"   => environment,
    "isFallback"    => is_fallback,
    "secretComment" => secret_comment,
    "secretKey"     => secret_key,
    "secretPath"    => secret_path,
    "secretValue"   => secret_value,
    "type"          => secret_type,
    "version"       => version,
    "workspace"     => workspace,
  }
end

#to_json(options = nil) ⇒ Object



1504
1505
1506
# File 'lib/schemas.rb', line 1504

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