Class: Hocon::Impl::Parseable

Inherits:
Object
  • Object
show all
Defined in:
lib/hocon/impl/parseable.rb

Direct Known Subclasses

ParseableFile

Defined Under Namespace

Classes: ParseableFile

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.force_parsed_to_object(value) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/hocon/impl/parseable.rb', line 52

def self.force_parsed_to_object(value)
  if value.is_a? Hocon::Impl::AbstractConfigObject
    value
  else
    raise ConfigWrongTypeError.new(value.origin, "", "object at file root",
                                   value.value_type.name)
  end
end

.new_file(file_path, options) ⇒ Object



40
41
42
# File 'lib/hocon/impl/parseable.rb', line 40

def self.new_file(file_path, options)
  ParseableFile.new(file_path, options)
end

Instance Method Details

#include_contextObject



48
49
50
# File 'lib/hocon/impl/parseable.rb', line 48

def include_context
  @include_context
end

#optionsObject



44
45
46
# File 'lib/hocon/impl/parseable.rb', line 44

def options
  @initial_options
end

#parseObject



61
62
63
# File 'lib/hocon/impl/parseable.rb', line 61

def parse
  self.class.force_parsed_to_object(parse_value(options))
end

#parse_value(base_options) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/hocon/impl/parseable.rb', line 65

def parse_value(base_options)
  # note that we are NOT using our "initialOptions",
  # but using the ones from the passed-in options. The idea is that
  # callers can get our original options and then parse with different
  # ones if they want.
  options = fixup_options(base_options)

  # passed-in options can override origin
  origin =
      if options.origin_description
        Hocon::Impl::SimpleConfigOrigin.new_simple(options.origin_description)
      else
        @initial_origin
      end
  parse_value_from_origin(origin, options)
end