Class: DdbRuby::FifthEdition::Notes
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Notes
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3266 def self.from_dynamic!(d) d = Types::Hash[d] new( allies: d.fetch("allies"), personal_possessions: d.fetch("personalPossessions"), other_holdings: d.fetch("otherHoldings"), organizations: d.fetch("organizations"), enemies: d.fetch("enemies"), backstory: d.fetch("backstory"), other_notes: d.fetch("otherNotes"), ) end |
.from_json!(json) ⇒ Object
3279 3280 3281 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3279 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3283 def to_dynamic { "allies" => allies, "personalPossessions" => personal_possessions, "otherHoldings" => other_holdings, "organizations" => organizations, "enemies" => enemies, "backstory" => backstory, "otherNotes" => other_notes, } end |
#to_json(options = nil) ⇒ Object
3295 3296 3297 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3295 def to_json( = nil) JSON.generate(to_dynamic, ) end |