Class: Hocon::Impl::AbstractConfigObject

Inherits:
AbstractConfigValue show all
Includes:
ConfigObject
Defined in:
lib/hocon/impl/abstract_config_object.rb

Direct Known Subclasses

SimpleConfigObject

Constant Summary

Constants inherited from AbstractConfigValue

Hocon::Impl::AbstractConfigValue::ConfigImplUtil

Instance Attribute Summary

Attributes inherited from AbstractConfigValue

#origin

Instance Method Summary collapse

Methods inherited from AbstractConfigValue

#ignores_fallbacks?, #indent, #render, #render_to_sb, #render_value_to_sb, #require_not_ignoring_fallbacks, #resolve_status, #to_s, #with_fallback, #with_origin

Constructor Details

#initialize(origin) ⇒ AbstractConfigObject

Returns a new instance of AbstractConfigObject.



12
13
14
15
# File 'lib/hocon/impl/abstract_config_object.rb', line 12

def initialize(origin)
  super(origin)
  @config = Hocon::Impl::SimpleConfig.new(self)
end

Instance Method Details

#merge_origins(stack) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hocon/impl/abstract_config_object.rb', line 33

def merge_origins(stack)
  if stack.empty?
    raise ConfigBugError, "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_copy(origin) ⇒ Object



29
30
31
# File 'lib/hocon/impl/abstract_config_object.rb', line 29

def new_copy(origin)
  new_copy_with_status(resolve_status, origin)
end

#to_configObject



17
18
19
# File 'lib/hocon/impl/abstract_config_object.rb', line 17

def to_config
  @config
end

#to_fallback_valueObject



21
22
23
# File 'lib/hocon/impl/abstract_config_object.rb', line 21

def to_fallback_value
  self
end

#value_typeObject



25
26
27
# File 'lib/hocon/impl/abstract_config_object.rb', line 25

def value_type
  Hocon::ConfigValueType::OBJECT
end