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
3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3386 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
3399 3400 3401 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3399 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3403 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
3415 3416 3417 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3415 def to_json( = nil) JSON.generate(to_dynamic, ) end |