Method: Megam::Components.json_create

Defined in:
lib/megam/core/components.rb

.json_create(o) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/megam/core/components.rb', line 188

def self.json_create(o)
  asm = new
  asm.id(o["id"]) if o.has_key?("id")
  asm.name(o["name"]) if o.has_key?("name")
  asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
  asm.inputs(o["inputs"]) if o.has_key?("inputs")
  asm.outputs(o["outputs"]) if o.has_key?("outputs")

  ar = o["artifacts"]
  asm.artifacts[:artifact_type] = ar["artifact_type"] if ar && ar.has_key?("artifact_type")
  asm.artifacts[:content] = ar["content"] if ar && ar.has_key?("content")
  asm.artifacts[:artifact_requirements] = ar["artifact_requirements"] if ar && ar.has_key?("artifact_requirements")

  asm.related_components(o["related_components"]) if o.has_key?("related_components")
  asm.operations(o["operations"]) if o.has_key?("operations")      
  asm.status(o["status"]) if o.has_key?("status")
  asm.created_at(o["created_at"]) if o.has_key?("created_at")
  asm
end