class Hocon::Impl::SimpleConfigDocument

Public Class Methods

new(parsed_node, parse_options) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 11
def initialize(parsed_node, parse_options)
  @config_node_tree = parsed_node
  @parse_options = parse_options
end

Public Instance Methods

==(other) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 44
def ==(other)
  other.class.ancestors.include?(Hocon::Parser::ConfigDocument) && render == other.render
end
has_value?(path) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 36
def has_value?(path)
  @config_node_tree.has_value(path)
end
hash() click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 48
def hash
  render.hash
end
remove_value(path) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 32
def remove_value(path)
  self.class.new(@config_node_tree.set_value(path, nil, @parse_options.syntax), @parse_options)
end
render() click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 40
def render
  @config_node_tree.render
end
set_config_value(path, new_value) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 26
def set_config_value(path, new_value)
  options = Hocon::ConfigRenderOptions.defaults
  options.origin_comments = false
  set_value(path, new_value.render(options).strip)
end
set_value(path, new_value) click to toggle source
# File lib/hocon/impl/simple_config_document.rb, line 16
def set_value(path, new_value)
  origin = Hocon::Impl::SimpleConfigOrigin.new_simple("single value parsing")
  reader = StringIO.new(new_value)
  tokens = Hocon::Impl::Tokenizer.tokenize(origin, reader, @parse_options.syntax)
  parsed_value = Hocon::Impl::ConfigDocumentParser.parse_value(tokens, origin, @parse_options)
  reader.close

  self.class.new(@config_node_tree.set_value(path, parsed_value, @parse_options.syntax), @parse_options)
end