Class: CreateAPISchemaFilesItem

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



36027
36028
36029
36030
36031
36032
36033
36034
# File 'lib/schemas.rb', line 36027

def self.from_dynamic!(d)
  d = Types::Hash[d]
  new(
    content: d["content"],
    path:    d["path"],
    root:    d["root"] ? CreateAPISchemaFilesItemRoot.from_dynamic!(d["root"]) : nil,
  )
end

.from_json!(json) ⇒ Object



36036
36037
36038
# File 'lib/schemas.rb', line 36036

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

Instance Method Details

#to_dynamicObject



36040
36041
36042
36043
36044
36045
36046
# File 'lib/schemas.rb', line 36040

def to_dynamic
  {
    "content" => content,
    "path"    => path,
    "root"    => root&.to_dynamic,
  }
end

#to_json(options = nil) ⇒ Object



36048
36049
36050
# File 'lib/schemas.rb', line 36048

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