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



2511
2512
2513
2514
2515
2516
2517
2518
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2511

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



2520
2521
2522
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2520

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

Instance Method Details

#to_dynamicObject



2524
2525
2526
2527
2528
2529
2530
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2524

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

#to_json(options = nil) ⇒ Object



2532
2533
2534
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2532

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