Class: SchemaFileBase

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



36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
# File 'lib/schemas.rb', line 36582

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

.from_json!(json) ⇒ Object



36595
36596
36597
# File 'lib/schemas.rb', line 36595

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

Instance Method Details

#to_dynamicObject



36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
# File 'lib/schemas.rb', line 36599

def to_dynamic
  {
    "createdAt" => created_at,
    "createdBy" => created_by,
    "id"        => id,
    "name"      => schema_file_base_name,
    "path"      => path,
    "updatedAt" => updated_at,
    "updatedBy" => updated_by,
  }
end

#to_json(options = nil) ⇒ Object



36611
36612
36613
# File 'lib/schemas.rb', line 36611

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