Class: DdbRuby::FifthEdition::OptionsClass

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/ddb_ruby/fifth_edition/structs.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



869
870
871
872
873
874
875
876
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 869

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    component_id:      d.fetch("componentId"),
    component_type_id: d.fetch("componentTypeId"),
    definition:        Definition2.from_dynamic!(d.fetch("definition")),
  )
end

.from_json!(json) ⇒ Object



878
879
880
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 878

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



882
883
884
885
886
887
888
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 882

def to_dynamic
  {
    "componentId"     => component_id,
    "componentTypeId" => component_type_id,
    "definition"      => definition.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



890
891
892
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 890

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end