Class: Cadenya::Types::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenya/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata: nil, spec: nil, info: nil, state: nil) ⇒ Model

Returns a new instance of Model.



3339
3340
3341
3342
3343
3344
# File 'lib/cadenya/types.rb', line 3339

def initialize(metadata: nil, spec: nil, info: nil, state: nil)
  @metadata = 
  @spec = spec
  @info = info
  @state = state
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



3337
3338
3339
# File 'lib/cadenya/types.rb', line 3337

def info
  @info
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3337
3338
3339
# File 'lib/cadenya/types.rb', line 3337

def 
  @metadata
end

#specObject (readonly)

Returns the value of attribute spec.



3337
3338
3339
# File 'lib/cadenya/types.rb', line 3337

def spec
  @spec
end

#stateObject (readonly)

Returns the value of attribute state.



3337
3338
3339
# File 'lib/cadenya/types.rb', line 3337

def state
  @state
end

Class Method Details

.from_json(data) ⇒ Object



3346
3347
3348
3349
3350
3351
3352
3353
# File 'lib/cadenya/types.rb', line 3346

def self.from_json(data)
  new(
    metadata: data["metadata"].nil? ? nil : Types::ResourceMetadata.from_json(data["metadata"]),
    spec: data["spec"].nil? ? nil : Types::ModelSpec.from_json(data["spec"]),
    info: data["info"].nil? ? nil : Types::ModelInfo.from_json(data["info"]),
    state: data["state"],
  )
end

Instance Method Details

#to_hObject



3355
3356
3357
3358
3359
3360
3361
3362
# File 'lib/cadenya/types.rb', line 3355

def to_h
  {
    metadata: Util.plain(@metadata),
    spec: Util.plain(@spec),
    info: Util.plain(@info),
    state: Util.plain(@state),
  }.reject { |_k, v| v.nil? }
end