Class: DdbRuby::FifthEdition::Configuration

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



2400
2401
2402
2403
2404
2405
2406
2407
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2400

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    starting_equipment_type: d.fetch("startingEquipmentType"),
    ability_score_type:      d.fetch("abilityScoreType"),
    show_help_text:          d.fetch("showHelpText"),
  )
end

.from_json!(json) ⇒ Object



2409
2410
2411
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2409

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

Instance Method Details

#to_dynamicObject



2413
2414
2415
2416
2417
2418
2419
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2413

def to_dynamic
  {
    "startingEquipmentType" => starting_equipment_type,
    "abilityScoreType"      => ability_score_type,
    "showHelpText"          => show_help_text,
  }
end

#to_json(options = nil) ⇒ Object



2421
2422
2423
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2421

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