Class: DdbRuby::FifthEdition::ClassFeatureDefinition
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::ClassFeatureDefinition
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2079 def self.from_dynamic!(d) d = Types::Hash[d] new( id: d.fetch("id"), definition_key: d.fetch("definitionKey"), entity_type_id: d.fetch("entityTypeId"), display_order: d.fetch("displayOrder"), definition_name: d.fetch("name"), description: d.fetch("description"), snippet: d.fetch("snippet"), activation: d.fetch("activation"), multi_class_description: d["multiClassDescription"], required_level: d.fetch("requiredLevel"), is_sub_class_feature: d["isSubClassFeature"], limited_use: d["limitedUse"]&.map { |x| LimitedUseElement.from_dynamic!(x) }, hide_in_builder: d.fetch("hideInBuilder"), hide_in_sheet: d.fetch("hideInSheet"), source_id: d.fetch("sourceId"), source_page_number: d.fetch("sourcePageNumber"), creature_rules: d.fetch("creatureRules").map { |x| CreatureRule.from_dynamic!(x) }, level_scales: d["levelScales"]&.map { |x| LevelScale.from_dynamic!(x) }, infusion_rules: d["infusionRules"]&.map { |x| InfusionRule.from_dynamic!(x) }, spell_list_ids: d.fetch("spellListIds"), class_id: d["classId"], feature_type: d.fetch("featureType"), sources: d.fetch("sources").map { |x| Source.from_dynamic!(x) }, affected_feature_definition_keys: d.fetch("affectedFeatureDefinitionKeys"), entity_type: d.fetch("entityType"), entity_id: d.fetch("entityID"), is_called_out: d["isCalledOut"], entity_race_id: d["entityRaceId"], entity_race_type_id: d["entityRaceTypeId"], display_configuration: d["displayConfiguration"] ? DisplayConfiguration.from_dynamic!(d["displayConfiguration"]) : nil, ) end |
.from_json!(json) ⇒ Object
2115 2116 2117 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2115 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2119 def to_dynamic { "id" => id, "definitionKey" => definition_key, "entityTypeId" => entity_type_id, "displayOrder" => display_order, "name" => definition_name, "description" => description, "snippet" => snippet, "activation" => activation, "multiClassDescription" => multi_class_description, "requiredLevel" => required_level, "isSubClassFeature" => is_sub_class_feature, "limitedUse" => limited_use&.map { |x| x.to_dynamic }, "hideInBuilder" => hide_in_builder, "hideInSheet" => hide_in_sheet, "sourceId" => source_id, "sourcePageNumber" => source_page_number, "creatureRules" => creature_rules.map { |x| x.to_dynamic }, "levelScales" => level_scales&.map { |x| x.to_dynamic }, "infusionRules" => infusion_rules&.map { |x| x.to_dynamic }, "spellListIds" => spell_list_ids, "classId" => class_id, "featureType" => feature_type, "sources" => sources.map { |x| x.to_dynamic }, "affectedFeatureDefinitionKeys" => affected_feature_definition_keys, "entityType" => entity_type, "entityID" => entity_id, "isCalledOut" => is_called_out, "entityRaceId" => entity_race_id, "entityRaceTypeId" => entity_race_type_id, "displayConfiguration" => display_configuration&.to_dynamic, } end |
#to_json(options = nil) ⇒ Object
2154 2155 2156 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2154 def to_json( = nil) JSON.generate(to_dynamic, ) end |