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



1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/schemas.rb', line 1513

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



1528
1529
1530
# File 'lib/schemas.rb', line 1528

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

Instance Method Details

#to_dynamicObject



1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
# File 'lib/schemas.rb', line 1532

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



1546
1547
1548
# File 'lib/schemas.rb', line 1546

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