Class: APIBase

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



35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
# File 'lib/schemas.rb', line 35579

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    created_at:    d["createdAt"],
    created_by:    d["createdBy"],
    description:   d["description"],
    id:            d["id"],
    api_base_name: d["name"],
    summary:       d["summary"],
    updated_at:    d["updatedAt"],
    updated_by:    d["updatedBy"],
  )
end

.from_json!(json) ⇒ Object



35593
35594
35595
# File 'lib/schemas.rb', line 35593

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

Instance Method Details

#to_dynamicObject



35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
# File 'lib/schemas.rb', line 35597

def to_dynamic
  {
    "createdAt"   => created_at,
    "createdBy"   => created_by,
    "description" => description,
    "id"          => id,
    "name"        => api_base_name,
    "summary"     => summary,
    "updatedAt"   => updated_at,
    "updatedBy"   => updated_by,
  }
end

#to_json(options = nil) ⇒ Object



35610
35611
35612
# File 'lib/schemas.rb', line 35610

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