Class: DdbRuby::FifthEdition::Sense

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



2628
2629
2630
2631
2632
2633
2634
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2628

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

.from_json!(json) ⇒ Object



2636
2637
2638
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2636

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

Instance Method Details

#to_dynamicObject



2640
2641
2642
2643
2644
2645
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2640

def to_dynamic
  {
    "senseId" => sense_id,
    "notes"   => notes,
  }
end

#to_json(options = nil) ⇒ Object



2647
2648
2649
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2647

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