applyModifiers iterates through each SELECT attribute for this query and applies the associated modifier to the attribute's output value.
(path string, info os.FileInfo)
| 21 | // applyModifiers iterates through each SELECT attribute for this query |
| 22 | // and applies the associated modifier to the attribute's output value. |
| 23 | func (q *Query) applyModifiers(path string, info os.FileInfo) (map[string]interface{}, error) { |
| 24 | results := make(map[string]interface{}, len(q.Attributes)) |
| 25 | |
| 26 | for _, attribute := range q.Attributes { |
| 27 | value, err := transform.DefaultFormatValue(attribute, path, info) |
| 28 | if err != nil { |
| 29 | return map[string]interface{}{}, err |
| 30 | } |
| 31 | |
| 32 | if _, ok := q.Modifiers[attribute]; !ok { |
| 33 | results[attribute] = value |
| 34 | continue |
| 35 | } |
| 36 | |
| 37 | for _, m := range q.Modifiers[attribute] { |
| 38 | value, err = transform.Format(&transform.FormatParams{ |
| 39 | Attribute: attribute, |
| 40 | Path: path, |
| 41 | Info: info, |
| 42 | Value: value, |
| 43 | Name: m.Name, |
| 44 | Args: m.Arguments, |
| 45 | }) |
| 46 | if err != nil { |
| 47 | return map[string]interface{}{}, err |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | results[attribute] = value |
| 52 | } |
| 53 | |
| 54 | return results, nil |
| 55 | } |
no test coverage detected