Class: DdbRuby::FifthEdition::Activation

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



52
53
54
55
56
57
58
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 52

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    activation_time: d.fetch("activationTime"),
    activation_type: d.fetch("activationType"),
  )
end

.from_json!(json) ⇒ Object



60
61
62
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 60

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

Instance Method Details

#to_dynamicObject



64
65
66
67
68
69
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 64

def to_dynamic
  {
    "activationTime" => activation_time,
    "activationType" => activation_type,
  }
end

#to_json(options = nil) ⇒ Object



71
72
73
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 71

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