Class: EncryptSymmetricOptions

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



547
548
549
550
551
552
553
# File 'lib/schemas.rb', line 547

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

.from_json!(json) ⇒ Object



555
556
557
# File 'lib/schemas.rb', line 555

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

Instance Method Details

#to_dynamicObject



559
560
561
562
563
564
# File 'lib/schemas.rb', line 559

def to_dynamic
  {
    "key"       => key,
    "plaintext" => plaintext,
  }
end

#to_json(options = nil) ⇒ Object



566
567
568
# File 'lib/schemas.rb', line 566

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