File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ func (dm *DataModel) Version() string {
6565 return string (dm .version )
6666}
6767
68+ // Each iterates over all parameters in the DataModel. Iteration can be stopped
69+ // by returning false from the callback function.
70+ func (dm * DataModel ) Each (fn func (p Parameter ) (cont bool )) {
71+ dm .values .forEach (func (p Parameter ) (cont bool ) {
72+ return fn (p )
73+ })
74+ }
75+
6876// GetAll returns one or more parameters prefixed with the given path.
6977func (dm * DataModel ) GetAll (path string ) (params []Parameter , ok bool ) {
7078 if ! strings .HasSuffix (path , "." ) {
Original file line number Diff line number Diff line change @@ -33,6 +33,12 @@ func NormalizeParameters(params map[string]Parameter) {
3333 }
3434}
3535
36+ // Name returns parameter name.
37+ func (p Parameter ) Name () string {
38+ tokens := strings .Split (p .Path , "." )
39+ return tokens [len (tokens )- 1 ]
40+ }
41+
3642// GetValue returns a parameter value. If the parameter has a generator function
3743// it will be used to produce a value, otherwise the value from the parameter
3844// will be returned.
You can’t perform that action at this time.
0 commit comments