Class: DdbRuby::FifthEdition::CharacterElement
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::CharacterElement
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 723 def self.from_dynamic!(d) d = Types::Hash[d] new( user_id: d.fetch("userId"), username: d.fetch("username"), character_id: d.fetch("characterId"), character_name: d.fetch("characterName"), character_url: d.fetch("characterUrl"), avatar_url: d.fetch("avatarUrl"), privacy_type: d.fetch("privacyType"), campaign_id: d.fetch("campaignId"), is_assigned: d.fetch("isAssigned"), ) end |
.from_json!(json) ⇒ Object
738 739 740 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 738 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
742 743 744 745 746 747 748 749 750 751 752 753 754 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 742 def to_dynamic { "userId" => user_id, "username" => username, "characterId" => character_id, "characterName" => character_name, "characterUrl" => character_url, "avatarUrl" => avatar_url, "privacyType" => privacy_type, "campaignId" => campaign_id, "isAssigned" => is_assigned, } end |
#to_json(options = nil) ⇒ Object
756 757 758 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 756 def to_json( = nil) JSON.generate(to_dynamic, ) end |