GetBoolean allows returning the attribute with the given key as a bool. If the attribute JSON/YAML content is not a JSON boolean (or a JSON string that can be converted into a JSON boolean), then the result will be the `false` zero value and an error is raised. String values can be converted to bo
(key string, errorHolder *error)
| 152 | // to receive any error that might have be raised during the attribute |
| 153 | // decoding |
| 154 | func (attributes Attributes) GetBoolean(key string, errorHolder *error) bool { |
| 155 | return attributes.getPrimitive( |
| 156 | key, |
| 157 | false, |
| 158 | "boolean", |
| 159 | func(attributes Attributes, key string, attributeType string) (interface{}, error) { |
| 160 | var convertedValue interface{} |
| 161 | var retryError error |
| 162 | switch attributeType { |
| 163 | case "string": |
| 164 | var convError error |
| 165 | convertedValue, convError = strconv.ParseBool(attributes.GetString(key, &retryError)) |
| 166 | if retryError == nil { |
| 167 | retryError = convError |
| 168 | } |
| 169 | } |
| 170 | return convertedValue, retryError |
| 171 | }, |
| 172 | errorHolder).(bool) |
| 173 | } |
| 174 | |
| 175 | // Get allows returning the attribute with the given key |
| 176 | // as an interface. The underlying type of the returned interface |
no test coverage detected