Class: DdbRuby::FifthEdition::RacialTrait

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



3883
3884
3885
3886
3887
3888
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3883

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

.from_json!(json) ⇒ Object



3890
3891
3892
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3890

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

Instance Method Details

#to_dynamicObject



3894
3895
3896
3897
3898
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3894

def to_dynamic
  {
    "definition" => definition.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



3900
3901
3902
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3900

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