Class: DdbRuby::FifthEdition::DefinitionRange

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



1538
1539
1540
1541
1542
1543
1544
1545
1546
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1538

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    origin:      d.fetch("origin"),
    range_value: d.fetch("rangeValue"),
    aoe_type:    d.fetch("aoeType"),
    aoe_value:   d.fetch("aoeValue"),
  )
end

.from_json!(json) ⇒ Object



1548
1549
1550
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1548

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

Instance Method Details

#to_dynamicObject



1552
1553
1554
1555
1556
1557
1558
1559
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1552

def to_dynamic
  {
    "origin"     => origin,
    "rangeValue" => range_value,
    "aoeType"    => aoe_type,
    "aoeValue"   => aoe_value,
  }
end

#to_json(options = nil) ⇒ Object



1561
1562
1563
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 1561

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