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



888
889
890
891
892
893
894
895
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 888

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



897
898
899
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 897

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

Instance Method Details

#to_dynamicObject



901
902
903
904
905
906
907
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 901

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

#to_json(options = nil) ⇒ Object



909
910
911
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 909

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