Module: Hocon::ConfigValue
- Includes:
- ConfigMergeable
- Included in:
- ConfigList, ConfigObject, Impl::AbstractConfigValue, Impl::Container
- Defined in:
- lib/hocon/config_value.rb
Overview
An immutable value, following the <a href=“json.org”>JSON</a> type schema.
<p> Because this object is immutable, it is safe to use from multiple threads and there’s no need for “defensive copies.”
<p> Do not implement interface ConfigValue; it should only be implemented by the config library. Arbitrary implementations will not work because the library internals assume a specific concrete implementation. Also, this interface is likely to grow new methods over time, so third-party implementations will break.
Instance Method Summary collapse
-
#at_key(key) ⇒ Object
Places the value inside a Config at the given key.
-
#at_path(path) ⇒ Object
Places the value inside a Config at the given path.
-
#origin ⇒ Object
The origin of the value (file, line number, etc.), for debugging and error messages.
-
#render(options) ⇒ Object
Renders the config value to a string, using the provided options.
-
#unwrapped ⇒ Object
Returns the value as a plain Java boxed value, that is, a String, Number, Boolean, Map<String,Object>, List<Object>, or null, matching the #valueType() of this ConfigValue.
-
#value_type ⇒ Object
The ConfigValueType of the value; matches the JSON type schema.
- #with_fallback(other) ⇒ Object
-
#with_origin(origin) ⇒ Object
Returns a ConfigValue based on this one, but with the given origin.
Instance Method Details
#at_key(key) ⇒ Object
Places the value inside a Config at the given key. See also ConfigValue#atPath(String).
104 105 106 |
# File 'lib/hocon/config_value.rb', line 104 def at_key(key) raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `at_key` (#{self.class})" end |
#at_path(path) ⇒ Object
Places the value inside a Config at the given path. See also ConfigValue#atKey(String).
92 93 94 |
# File 'lib/hocon/config_value.rb', line 92 def at_path(path) raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `at_path` (#{self.class})" end |
#origin ⇒ Object
The origin of the value (file, line number, etc.), for debugging and error messages.
30 31 32 |
# File 'lib/hocon/config_value.rb', line 30 def origin raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `origin` (#{self.class})" end |
#render(options) ⇒ Object
Renders the config value to a string, using the provided options.
<p> If the config value has not been resolved (see Config#resolve), it’s possible that it can’t be rendered as valid HOCON. In that case the rendering should still be useful for debugging but you might not be able to parse it. If the value has been resolved, it will always be parseable.
<p> If the config value has been resolved and the options disable all HOCON-specific features (such as comments), the rendering will be valid JSON. If you enable HOCON-only features such as comments, the rendering will not be valid JSON.
75 76 77 |
# File 'lib/hocon/config_value.rb', line 75 def render() raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `render` (#{self.class})" end |
#unwrapped ⇒ Object
Returns the value as a plain Java boxed value, that is, a String, Number, Boolean, Map<String,Object>, List<Object>, or null, matching the #valueType() of this ConfigValue. If the value is a ConfigObject or ConfigList, it is recursively unwrapped.
52 53 54 |
# File 'lib/hocon/config_value.rb', line 52 def unwrapped raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `unwrapped` (#{self.class})" end |
#value_type ⇒ Object
The ConfigValueType of the value; matches the JSON type schema.
40 41 42 |
# File 'lib/hocon/config_value.rb', line 40 def value_type raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `value_type` (#{self.class})" end |
#with_fallback(other) ⇒ Object
79 80 81 |
# File 'lib/hocon/config_value.rb', line 79 def with_fallback(other) raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `with_fallback` (#{self.class})" end |
#with_origin(origin) ⇒ Object
Returns a ConfigValue based on this one, but with the given origin. This is useful when you are parsing a new format of file or setting comments for a single ConfigValue.
118 119 120 |
# File 'lib/hocon/config_value.rb', line 118 def with_origin(origin) raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `ConfigValue` must implement `with_origin` (#{self.class})" end |