module Hocon::Impl::AbstractConfigObject

Constants

ConfigBugOrBrokenError
ConfigNotResolvedError

Public Class Methods

merge_origins(stack) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 143
def self.merge_origins(stack)
  if stack.empty?
    raise ConfigBugOrBrokenError, "can't merge origins on empty list"
  end
  origins = []
  first_origin = nil
  num_merged = 0
  stack.each do |v|
    if first_origin.nil?
      first_origin = v.origin
    end

    if (v.is_a?(Hocon::Impl::AbstractConfigObject)) &&
        (v.resolve_status == Hocon::Impl::ResolveStatus::RESOLVED) &&
        v.empty?
      # don't include empty files or the .empty()
      # config in the description, since they are
      # likely to be "implementation details"
    else
      origins.push(v.origin)
      num_merged += 1
    end
  end

  if num_merged == 0
    # the configs were all empty, so just use the first one
    origins.push(first_origin)
  end

  Hocon::Impl::SimpleConfigOrigin.merge_origins(origins)
end
new(origin) click to toggle source
Calls superclass method Hocon::Impl::AbstractConfigValue.new
# File lib/hocon/impl/abstract_config_object.rb, line 22
def initialize(origin)
  super(origin)
  @config = Hocon::Impl::SimpleConfig.new(self)
end

Public Instance Methods

[](key) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 183
def [](key)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `[]`"
end
[]=(key, value) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 199
def []=(key, value)
  raise we_are_immutable("[]=")
end
attempt_peek_with_partial_resolve(key) click to toggle source

Look up the key on an only-partially-resolved object, with no transformation or type conversion of any kind; if 'this' is not resolved then try to look up the key anyway if possible.

@param key

key to look up

@return the value of the key, or null if known not to exist @throws ConfigNotResolvedError

if can't figure out key's value (or existence) without more
resolving
# File lib/hocon/impl/abstract_config_object.rb, line 88
def attempt_peek_with_partial_resolve(key)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `attempt_peek_with_partial_resolve`"
end
clear() click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 195
def clear
  raise we_are_immutable("clear")
end
construct_delayed_merge(origin, stack) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 131
def construct_delayed_merge(origin, stack)
  Hocon::Impl::ConfigDelayedMergeObject.new(origin, stack)
end
delete(key) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 211
def delete(key)
  raise we_are_immutable("delete")
end
merged_with_object(fallback) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 135
def merged_with_object(fallback)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `merged_with_object`"
end
new_copy(origin) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 127
def new_copy(origin)
  new_copy_with_status(resolve_status, origin)
end
new_copy_with_status(status, origin) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 123
def new_copy_with_status(status, origin)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `new_copy_with_status`"
end
peek_assuming_resolved(key, original_path) click to toggle source

This looks up the key with no transformation or type conversion of any kind, and returns null if the key is not present. The object must be resolved along the nodes needed to get the key or ConfigNotResolvedError will be thrown.

@param key @return the unmodified raw value or null

# File lib/hocon/impl/abstract_config_object.rb, line 70
def peek_assuming_resolved(key, original_path)
  begin
    attempt_peek_with_partial_resolve(key)
  rescue ConfigNotResolvedError => e
    raise Hocon::Impl::ConfigImpl.improve_not_resolved(original_path, e)
  end
end
peek_path(path) click to toggle source

Looks up the path with no transformation or type conversion. Returns null if the path is not found; throws ConfigException.NotResolved if we need to go through an unresolved node to look up the path.

# File lib/hocon/impl/abstract_config_object.rb, line 95
def peek_path(path)
  peek_path_from_obj(self, path)
end
peek_path_from_obj(obj, path) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 99
def peek_path_from_obj(obj, path)
  begin
    # we'll fail if anything along the path can't be looked at without resolving
    path_next = path.remainder
    v = obj.attempt_peek_with_partial_resolve(path.first)

    if path_next.nil?
      v
    else
      if v.is_a?(Hocon::Impl::AbstractConfigObject)
        peek_path_from_obj(v, path_next)
      else
        nil
      end
    end
  rescue ConfigNotResolvedError => e
    raise Hocon::Impl::ConfigImpl.improve_not_resolved(path, e)
  end
end
putAll(map) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 203
def putAll(map)
  raise we_are_immutable("putAll")
end
relativized(path) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 179
def relativized(path)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `relativized`"
end
remove(key) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 207
def remove(key)
  raise we_are_immutable("remove")
end
render_value_to_sb(sb, indent, at_root, options) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 187
def render_value_to_sb(sb, indent, at_root, options)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `render_value_to_sb`"
end
resolve_substitutions(context, source) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 175
def resolve_substitutions(context, source)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `resolve_substituions`"
end
to_config() click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 27
def to_config
  @config
end
to_fallback_value() click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 31
def to_fallback_value
  self
end
value_type() click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 119
def value_type
  Hocon::ConfigValueType::OBJECT
end
we_are_immutable(method) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 191
def we_are_immutable(method)
  Hocon::Impl::UnsupportedOperationError.new("ConfigObject is immutable, you can't call Map.#{method}")
end
with_fallback(mergeable) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 139
def with_fallback(mergeable)
  super(mergeable)
end
with_only_key(key) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 35
def with_only_key(key)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `with_only_key`"
end
with_only_path(path) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 51
def with_only_path(path)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `with_only_path`"
end
with_only_path_or_nil(path) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 47
def with_only_path_or_nil(path)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `with_only_path_or_nil`"
end
with_origin(origin) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 215
def with_origin(origin)
  super(origin)
end
with_path_value(path, value) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 59
def with_path_value(path, value)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `with_path_value`"
end
with_value(key, value) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 43
def with_value(key, value)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `with_value`"
end
without_key(key) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 39
def without_key(key)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `without_key`"
end
without_path(path) click to toggle source
# File lib/hocon/impl/abstract_config_object.rb, line 55
def without_path(path)
  raise ConfigBugOrBrokenError, "subclasses of AbstractConfigObject should override `without_path`"
end