Class: DdbRuby::FifthEdition::Campaign
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Campaign
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
776 777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 776 def self.from_dynamic!(d) d = Types::Hash[d] new( id: d.fetch("id"), campaign_name: d.fetch("name"), description: d.fetch("description"), link: d.fetch("link"), public_notes: d.fetch("publicNotes"), dm_user_id: d.fetch("dmUserId"), dm_username: d.fetch("dmUsername"), characters: d.fetch("characters").map { |x| CharacterElement.from_dynamic!(x) }, ) end |
.from_json!(json) ⇒ Object
790 791 792 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 790 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
794 795 796 797 798 799 800 801 802 803 804 805 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 794 def to_dynamic { "id" => id, "name" => campaign_name, "description" => description, "link" => link, "publicNotes" => public_notes, "dmUserId" => dm_user_id, "dmUsername" => dm_username, "characters" => characters.map { |x| x.to_dynamic }, } end |
#to_json(options = nil) ⇒ Object
807 808 809 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 807 def to_json( = nil) JSON.generate(to_dynamic, ) end |