class Hocon::Impl::ConfigDelayedMergeObject
This is just like ConfigDelayedMerge except we know statically that it will turn out to be an object.
Attributes
Public Class Methods
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 12 def initialize(origin, stack) super(origin) @stack = stack if stack.empty? raise Hocon::ConfigError::ConfigBugOrBrokenError.new("creating empty delayed merge value", nil) end if !@stack[0].is_a? Hocon::Impl::AbstractConfigObject error_message = "created a delayed merge object not guaranteed to be an object" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) end stack.each do |v| if v.is_a?(Hocon::Impl::ConfigDelayedMergeObject) || v.is_a?(Hocon::Impl::ConfigDelayedMergeObject) error_message = "placed nested DelayedMerge in a ConfigDelayedMerge, should have consolidated stack" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) end end end
Calls superclass method
Hocon::Impl::AbstractConfigObject::new
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 151 def self.not_resolved error_message = "need to Config#resolve() before using this object, see the API docs for Config#resolve()" Hocon::ConfigError::ConfigNotResolvedError.new(error_message, nil) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 192 def self.unmergeable?(object) # Ruby note: This is the best way I could find to simulate # else if (layer instanceof Unmergeable) in java since we're including # the Unmergeable module instead of extending an Unmergeable class object.class.included_modules.include?(Hocon::Impl::Unmergeable) end
Public Instance Methods
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 133 def ==(other) # note that "origin" is deliberately NOT part of equality if other.is_a? Hocon::Impl::ConfigDelayedMergeObject can_equal(other) && (@stack == other.stack || @stack.equal?(other.stack)) else false end end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 160 def [](key) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 199 def attempt_peek_with_partial_resolve(key) # a partial resolve of a ConfigDelayedMergeObject always results in a # SimpleConfigObject because all the substitutions in the stack get # resolved in order to look up the partial. # So we know here that we have not been resolved at all even # partially. # Given that, all this code is probably gratuitous, since the app code # is likely broken. But in general we only throw NotResolved if you try # to touch the exact key that isn't resolved, so this is in that # spirit. # we'll be able to return a key if we have a value that ignores # fallbacks, prior to any unmergeable values. @stack.each do |layer| if layer.is_a?(Hocon::Impl::AbstractConfigObject) v = layer.attempt_peek_with_partial_resolve(key) if !v.nil? if v.ignores_fallbacks? # we know we won't need to merge anything in to this # value return v else # we can't return this value because we know there are # unmergeable values later in the stack that may # contain values that need to be merged with this # value. we'll throw the exception when we get to those # unmergeable values, so continue here. next end elsif self.class.unmergeable?(layer) error_message = "should not be reached: unmergeable object returned null value" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) else # a non-unmergeable AbstractConfigObject that returned null # for the key in question is not relevant, we can keep # looking for a value. next end elsif self.class.unmergeable?(layer) error_message = "Key '#{key}' is not available at '#{origin.description}'" + "because value at '#{layer.origin.description}' has not been resolved" + " and may turn out to contain or hide '#{key}'. Be sure to Config#resolve()" + " before using a config object" raise Hocon::ConfigError::ConfigNotResolvedError.new(error_message, nil) elsif layer.resolved_status == ResolveStatus::UNRESOLVED # if the layer is not an object, and not a substitution or # merge, # then it's something that's unresolved because it _contains_ # an unresolved object... i.e. it's an array if !layer.is_a?(Hocon::Impl::ConfigList) error_message = "Expecting a list here, not #{layer}" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) end return nil else # non-object, but resolved, like an integer or something. # has no children so the one we're after won't be in it. # we would only have this in the stack in case something # else "looks back" to it due to a cycle. # anyway at this point we know we can't find the key anymore. if !layer.ignores_fallbacks? error_message = "resolved non-object should ignore fallbacks" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) end return nil end end # If we get here, then we never found anything unresolved which means # the ConfigDelayedMergeObject should not have existed. some # invariant was violated. error_message = "Delayed merge stack does not contain any unmergeable values" raise Hocon::ConfigError::ConfigBugOrBrokenError.new(error_message, nil) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 129 def can_equal(other) other.is_a? Hocon::Impl::ConfigDelayedMergeObject end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 172 def each raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 176 def empty? raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 66 def has_descendant?(descendant) Hocon::Impl::AbstractConfigValue.has_descendant_in_list?(@stack, descendant) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 164 def has_key?(key) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 168 def has_value?(value) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 142 def hash # note that "origin" is deliberately NOT part of equality @stack.hash end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 78 def ignores_fallbacks? Hocon::Impl::ConfigDelayedMerge.stack_ignores_fallbacks?(@stack) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 180 def keys raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 49 def make_replacement(context, skipping) Hocon::Impl::ConfigDelayedMerge.make_replacement(context, @stack, skipping) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 92 def merged_with_non_object(fallback) require_not_ignoring_fallbacks merged_stack_with_non_object(@stack, fallback) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 88 def merged_with_object(fallback) merged_with_non_object(fallback) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 82 def merged_with_the_unmergeable(fallback) require_not_ignoring_fallbacks merged_stack_with_the_unmergeable(@stack, fallback) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 36 def new_copy(status, origin) if status != resolve_status raise Hocon::ConfigError::ConfigBugOrBrokenError.new( "attempt to create resolved ConfigDelayedMergeObject") end Hocon::Impl::ConfigDelayedMergeObject.new(origin, @stack) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 70 def relativized(prefix) new_stack = [] @stack.each { |o| new_stack << o.relativized(prefix) } self.class.new(origin, new_stack) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 147 def render_to_sb(sb, indent, at_root, at_key, options) Hocon::Impl::ConfigDelayedMerge.render_value_to_sb_from_stack(@stack, sb, indent, at_root, at_key, options) end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 57 def replace_child(child, replacement) new_stack = Hocon::Impl::AbstractConfigValue.replace_child_in_list(@stack, child, replacement) if new_stack == nil nil else self.class.new(origin, new_stack) end end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 53 def resolve_status Hocon::Impl::ResolveStatus::UNRESOLVED end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 44 def resolve_substitutions(context, source) merged = Hocon::Impl::ConfigDelayedMerge.resolve_substitutions(self, @stack, context, source) merged.as_object_result end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 188 def size raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 125 def unmerged_values @stack end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 156 def unwrapped raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 184 def values raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 101 def with_only_key(key) raise self.class.not_resolved end
No implementation of withFallback here, just use the implementation in the super-class
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 113 def with_only_path(key) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 109 def with_only_path_or_nil(key) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 121 def with_value(key_or_path, value = nil) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 105 def without_key(key) raise self.class.not_resolved end
Source
# File lib/hocon/impl/config_delayed_merge_object.rb, line 117 def without_path(key) raise self.class.not_resolved end