Class: SchemaFileContents

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



36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
# File 'lib/schemas.rb', line 36642

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

.from_json!(json) ⇒ Object



36656
36657
36658
# File 'lib/schemas.rb', line 36656

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

Instance Method Details

#to_dynamicObject



36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
# File 'lib/schemas.rb', line 36660

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

#to_json(options = nil) ⇒ Object



36673
36674
36675
# File 'lib/schemas.rb', line 36673

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