Class: DecryptSymmetricOptions

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



478
479
480
481
482
483
484
485
486
# File 'lib/schemas.rb', line 478

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    ciphertext: d.fetch("ciphertext"),
    iv:         d.fetch("iv"),
    key:        d.fetch("key"),
    tag:        d.fetch("tag"),
  )
end

.from_json!(json) ⇒ Object



488
489
490
# File 'lib/schemas.rb', line 488

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

Instance Method Details

#to_dynamicObject



492
493
494
495
496
497
498
499
# File 'lib/schemas.rb', line 492

def to_dynamic
  {
    "ciphertext" => ciphertext,
    "iv"         => iv,
    "key"        => key,
    "tag"        => tag,
  }
end

#to_json(options = nil) ⇒ Object



501
502
503
# File 'lib/schemas.rb', line 501

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