Class: SimpleAcp::Models::Metadata

Inherits:
Base
  • Object
show all
Defined in:
lib/simple_acp/models/metadata.rb

Overview

Full agent metadata

Class Method Summary collapse

Methods inherited from Base

#==, attribute, attributes, #hash, #initialize, own_attributes, #to_h, #to_json

Constructor Details

This class inherits a constructor from SimpleAcp::Models::Base

Class Method Details

.from_hash(hash) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/simple_acp/models/metadata.rb', line 124

def self.from_hash(hash)
  return nil if hash.nil?

  instance = super

  if hash["annotations"] || hash[:annotations]
    instance.annotations = Annotations.from_hash(hash["annotations"] || hash[:annotations])
  end

  if hash["author"] || hash[:author]
    instance.author = Author.from_hash(hash["author"] || hash[:author])
  end

  if hash["contributors"] || hash[:contributors]
    contributors = hash["contributors"] || hash[:contributors]
    instance.contributors = contributors.map { |c| Contributor.from_hash(c) }
  end

  if hash["capabilities"] || hash[:capabilities]
    capabilities = hash["capabilities"] || hash[:capabilities]
    instance.capabilities = capabilities.map { |c| Capability.from_hash(c) }
  end

  if hash["links"] || hash[:links]
    links = hash["links"] || hash[:links]
    instance.links = links.map { |l| Link.from_hash(l) }
  end

  if hash["dependencies"] || hash[:dependencies]
    dependencies = hash["dependencies"] || hash[:dependencies]
    instance.dependencies = dependencies.map { |d| Dependency.from_hash(d) }
  end

  instance
end