methods walks over a structure and scrubs its exported methods.
(rv reflect.Value, path Path, callbacks map[string]Path)
| 104 | |
| 105 | // methods walks over a structure and scrubs its exported methods. |
| 106 | func (s *Scrubber) methods(rv reflect.Value, path Path, callbacks map[string]Path) { |
| 107 | for i := 0; i < rv.NumMethod(); i++ { |
| 108 | if rv.Type().Method(i).PkgPath == "" { // exported |
| 109 | cb, ok := rv.Method(i).Interface().(func(*Partial)) |
| 110 | if !ok { |
| 111 | continue |
| 112 | } |
| 113 | |
| 114 | name := rv.Type().Method(i).Name |
| 115 | name = strings.ToLower(name[0:1]) + name[1:] |
| 116 | s.register(cb, append(path, name), callbacks) |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // register is called when a function/method is found in arguments array. It |
| 122 | // assigns an unique ID to the passed callback and stores it internally. |