Class: DdbRuby::FifthEdition::Language

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/ddb_ruby/fifth_edition/structs.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



2541
2542
2543
2544
2545
2546
2547
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2541

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

.from_json!(json) ⇒ Object



2549
2550
2551
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2549

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

Instance Method Details

#to_dynamicObject



2553
2554
2555
2556
2557
2558
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2553

def to_dynamic
  {
    "languageId" => language_id,
    "notes"      => notes,
  }
end

#to_json(options = nil) ⇒ Object



2560
2561
2562
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2560

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