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)
| 161 | // to receive any error that might have be raised during the attribute |
| 162 | // decoding |
| 163 | func (attributes Attributes) GetBoolean(key string, errorHolder *error) bool { |
| 164 | return attributes.getPrimitive( |
| 165 | key, |
| 166 | false, |
| 167 | "boolean", |
| 168 | func(attributes Attributes, key string, attributeType string) (interface{}, error) { |
| 169 | var convertedValue interface{} |
| 170 | var retryError error |
| 171 | switch attributeType { |
| 172 | case "string": |
| 173 | var convError error |
| 174 | convertedValue, convError = strconv.ParseBool(attributes.GetString(key, &retryError)) |
| 175 | if retryError == nil { |
| 176 | retryError = convError |
| 177 | } |
| 178 | } |
| 179 | return convertedValue, retryError |
| 180 | }, |
| 181 | errorHolder).(bool) |
| 182 | } |
| 183 | |
| 184 | // Get allows returning the attribute with the given key |
| 185 | // as an interface. The underlying type of the returned interface |