Class: ArbitraryOptions

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



450
451
452
453
454
455
# File 'lib/schemas.rb', line 450

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

.from_json!(json) ⇒ Object



457
458
459
# File 'lib/schemas.rb', line 457

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

Instance Method Details

#to_dynamicObject



461
462
463
464
465
# File 'lib/schemas.rb', line 461

def to_dynamic
  {
    "data" => data,
  }
end

#to_json(options = nil) ⇒ Object



467
468
469
# File 'lib/schemas.rb', line 467

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