MCPcopy Create free account
hub / github.com/cloudwan/gohan / NewResource

Function NewResource

schema/resource.go:98–112  ·  view source on GitHub ↗

NewResource is a constructor for a resource

(schema *Schema, properties map[string]interface{})

Source from the content-addressed store, hash-verified

96
97//NewResource is a constructor for a resource
98func NewResource(schema *Schema, properties map[string]interface{}) (*Resource, error) {
99 resource := &Resource{
100 schema: schema,
101 properties: properties,
102 }
103 resource.tags = make(Tags)
104 if schema.Parent != "" {
105 parentID, ok := properties[schema.Parent+"_id"]
106 if ok {
107 parentIDStr, _ := parentID.(string)
108 resource.SetParentID(parentIDStr)
109 }
110 }
111 return resource, nil
112}
113
114//String return string form representation
115func (resource *Resource) String() string {

Callers 2

LoadResourceMethod · 0.85
resource_test.goFile · 0.85

Calls 1

SetParentIDMethod · 0.95

Tested by

no test coverage detected