Class: Duo

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



1477
1478
1479
1480
1481
1482
1483
# File 'lib/schemas.rb', line 1477

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

.from_json!(json) ⇒ Object



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

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

Instance Method Details

#to_dynamicObject



1489
1490
1491
1492
1493
1494
# File 'lib/schemas.rb', line 1489

def to_dynamic
  {
    "host"      => host,
    "signature" => signature,
  }
end

#to_json(options = nil) ⇒ Object



1496
1497
1498
# File 'lib/schemas.rb', line 1496

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