Class: ImportExportFile

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



36425
36426
36427
36428
36429
36430
36431
# File 'lib/schemas.rb', line 36425

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

.from_json!(json) ⇒ Object



36433
36434
36435
# File 'lib/schemas.rb', line 36433

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

Instance Method Details

#to_dynamicObject



36437
36438
36439
36440
36441
36442
# File 'lib/schemas.rb', line 36437

def to_dynamic
  {
    "input" => input,
    "type"  => import_export_file_type,
  }
end

#to_json(options = nil) ⇒ Object



36444
36445
36446
# File 'lib/schemas.rb', line 36444

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