Class: DdbRuby::FifthEdition::ClassSpell
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::ClassSpell
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1846 1847 1848 1849 1850 1851 1852 1853 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1846 def self.from_dynamic!(d) d = Types::Hash[d] new( entity_type_id: d.fetch("entityTypeId"), character_class_id: d.fetch("characterClassId"), spells: d.fetch("spells").map { |x| Spell.from_dynamic!(x) }, ) end |
.from_json!(json) ⇒ Object
1855 1856 1857 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1855 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1859 1860 1861 1862 1863 1864 1865 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1859 def to_dynamic { "entityTypeId" => entity_type_id, "characterClassId" => character_class_id, "spells" => spells.map { |x| x.to_dynamic }, } end |
#to_json(options = nil) ⇒ Object
1867 1868 1869 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1867 def to_json( = nil) JSON.generate(to_dynamic, ) end |