Class: ProjectsResponse

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



2387
2388
2389
2390
2391
2392
# File 'lib/schemas.rb', line 2387

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    data: d.fetch("data").map { |x| ProjectResponse.from_dynamic!(x) },
  )
end

.from_json!(json) ⇒ Object



2394
2395
2396
# File 'lib/schemas.rb', line 2394

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

Instance Method Details

#to_dynamicObject



2398
2399
2400
2401
2402
# File 'lib/schemas.rb', line 2398

def to_dynamic
  {
    "data" => data.map { |x| x.to_dynamic },
  }
end

#to_json(options = nil) ⇒ Object



2404
2405
2406
# File 'lib/schemas.rb', line 2404

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