File: container.rb

package info (click to toggle)
ruby-hocon 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ruby: 7,903; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 1,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# encoding: utf-8

require_relative '../../hocon/impl'
require_relative '../../hocon/config_value'
require_relative '../../hocon/config_error'

# An AbstractConfigValue which contains other values. Java has no way to
# express "this has to be an AbstractConfigValue also" other than making
# AbstractConfigValue an interface which would be aggravating. But we can say
# we are a ConfigValue.
module Hocon::Impl::Container
  include Hocon::ConfigValue
  #
  # Replace a child of this value. CAUTION if replacement is null, delete the
  # child, which may also delete the parent, or make the parent into a
  # non-container.
  #
  def replace_child(child, replacement)
    raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Container` must implement `replace_child` (#{self.class})"
  end

  #
  # Super-expensive full traversal to see if descendant is anywhere
  # underneath this container.
  #
  def has_descendant?(descendant)
    raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of `Container` must implement `has_descendant?` (#{self.class})"
  end
end