Class: Attachment

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



2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
# File 'lib/schemas.rb', line 2646

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    file_name: d["fileName"],
    id:        d["id"],
    key:       d["key"],
    size:      d["size"],
    size_name: d["sizeName"],
    url:       d["url"],
  )
end

.from_json!(json) ⇒ Object



2658
2659
2660
# File 'lib/schemas.rb', line 2658

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

Instance Method Details

#to_dynamicObject



2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
# File 'lib/schemas.rb', line 2662

def to_dynamic
  {
    "fileName" => file_name,
    "id"       => id,
    "key"      => key,
    "size"     => size,
    "sizeName" => size_name,
    "url"      => url,
  }
end

#to_json(options = nil) ⇒ Object



2673
2674
2675
# File 'lib/schemas.rb', line 2673

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