Class: DdbRuby::FifthEdition::ClassClassFeature

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



2024
2025
2026
2027
2028
2029
2030
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2024

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    definition:  ClassFeatureDefinition.from_dynamic!(d.fetch("definition")),
    level_scale: d.fetch("levelScale") ? LevelScale.from_dynamic!(d.fetch("levelScale")) : nil,
  )
end

.from_json!(json) ⇒ Object



2032
2033
2034
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2032

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

Instance Method Details

#to_dynamicObject



2036
2037
2038
2039
2040
2041
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2036

def to_dynamic
  {
    "definition" => definition.to_dynamic,
    "levelScale" => level_scale&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



2043
2044
2045
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 2043

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