OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // HEAVILY adapted from github.com/golang/appengine/datastore | 5 // HEAVILY adapted from github.com/golang/appengine/datastore |
6 | 6 |
7 package datastore | 7 package datastore |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 set(pVal) | 199 set(pVal) |
200 } | 200 } |
201 if slice.IsValid() { | 201 if slice.IsValid() { |
202 slice.Set(reflect.Append(slice, v)) | 202 slice.Set(reflect.Append(slice, v)) |
203 } | 203 } |
204 return "" | 204 return "" |
205 } | 205 } |
206 | 206 |
207 func (p *structPLS) Save(withMeta bool) (PropertyMap, error) { | 207 func (p *structPLS) Save(withMeta bool) (PropertyMap, error) { |
| 208 if err := p.Problem(); err != nil { |
| 209 return nil, err |
| 210 } |
| 211 |
208 ret := PropertyMap(nil) | 212 ret := PropertyMap(nil) |
209 if withMeta { | 213 if withMeta { |
210 » » ret = p.GetAllMeta() | 214 » » ret = getMGS(p.o.Addr().Interface()).GetAllMeta() |
211 } else { | 215 } else { |
212 ret = make(PropertyMap, len(p.c.byName)) | 216 ret = make(PropertyMap, len(p.c.byName)) |
213 } | 217 } |
214 if _, err := p.save(ret, "", ShouldIndex); err != nil { | 218 if _, err := p.save(ret, "", ShouldIndex); err != nil { |
215 return nil, err | 219 return nil, err |
216 } | 220 } |
217 return ret, nil | 221 return ret, nil |
218 } | 222 } |
219 | 223 |
220 func (p *structPLS) getDefaultKind() string { | 224 func (p *structPLS) getDefaultKind() string { |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 switch val { | 584 switch val { |
581 case "on", "On", "true": | 585 case "on", "On", "true": |
582 return true, nil | 586 return true, nil |
583 case "off", "Off", "false": | 587 case "off", "Off", "false": |
584 return false, nil | 588 return false, nil |
585 } | 589 } |
586 return nil, fmt.Errorf("Toggle field has bad/missing default, go
t %q", val) | 590 return nil, fmt.Errorf("Toggle field has bad/missing default, go
t %q", val) |
587 } | 591 } |
588 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t
, val) | 592 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t
, val) |
589 } | 593 } |
OLD | NEW |