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



3915
3916
3917
3918
3919
3920
3921
3922
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3915

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



3924
3925
3926
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3924

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

Instance Method Details

#to_dynamicObject



3928
3929
3930
3931
3932
3933
3934
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3928

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

#to_json(options = nil) ⇒ Object



3936
3937
3938
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3936

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