예제 #1
0
파일: Model.go 프로젝트: zetaben/gouda
func (m *Model) translateObjectValue(v map[string]Value, p *reflect.StructValue) interface{} {
	for lbl, _ := range m.Attributes() {
		vl := v[strings.ToLower(lbl)]
		switch vl.Kind() {
		//TODO MakeZero ??
		case IntKind:
			tmp := reflect.NewValue(1).(*reflect.IntValue)
			tmp.Set(int(vl.Int()))
			p.FieldByName(lbl).SetValue(tmp)
		case StringKind:
			tmp := reflect.NewValue("").(*reflect.StringValue)
			tmp.Set(string(vl.String()))
			p.FieldByName(lbl).SetValue(tmp)
		}
	}
	m.object_cache[int(v[strings.ToLower(m.identifier)].Int())] = v
	return p.Interface()

}