Class: DdbRuby::FifthEdition::ChoicesBackground
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::ChoicesBackground
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 991 def self.from_dynamic!(d) d = Types::Hash[d] new( component_id: d.fetch("componentId"), component_type_id: d.fetch("componentTypeId"), id: d.fetch("id"), parent_choice_id: d.fetch("parentChoiceId"), background_type: d.fetch("type"), sub_type: d.fetch("subType"), option_value: d.fetch("optionValue"), label: d.fetch("label"), is_optional: d.fetch("isOptional"), is_infinite: d.fetch("isInfinite"), default_subtypes: d.fetch("defaultSubtypes"), display_order: d.fetch("displayOrder"), background_options: d.fetch("options"), option_ids: d.fetch("optionIds"), ) end |
.from_json!(json) ⇒ Object
1011 1012 1013 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1011 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1015 def to_dynamic { "componentId" => component_id, "componentTypeId" => component_type_id, "id" => id, "parentChoiceId" => parent_choice_id, "type" => background_type, "subType" => sub_type, "optionValue" => option_value, "label" => label, "isOptional" => is_optional, "isInfinite" => is_infinite, "defaultSubtypes" => default_subtypes, "displayOrder" => display_order, "options" => , "optionIds" => option_ids, } end |
#to_json(options = nil) ⇒ Object
1034 1035 1036 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1034 def to_json( = nil) JSON.generate(to_dynamic, ) end |