Class: PostApisBody

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schemas.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



20155
20156
20157
20158
20159
20160
20161
20162
# File 'lib/schemas.rb', line 20155

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    description:         d["description"],
    post_apis_body_name: d.fetch("name"),
    summary:             d["summary"],
  )
end

.from_json!(json) ⇒ Object



20164
20165
20166
# File 'lib/schemas.rb', line 20164

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

Instance Method Details

#to_dynamicObject



20168
20169
20170
20171
20172
20173
20174
# File 'lib/schemas.rb', line 20168

def to_dynamic
  {
    "description" => description,
    "name"        => post_apis_body_name,
    "summary"     => summary,
  }
end

#to_json(options = nil) ⇒ Object



20176
20177
20178
# File 'lib/schemas.rb', line 20176

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