class Hocon::Impl::SimpleConfigList
Constants
- ConfigBugOrBrokenError
- ResolveResult
-
value is allowed to be null
- ResolveStatus
Attributes
Public Class Methods
Source
# File lib/hocon/impl/simple_config_list.rb, line 24 def initialize(origin, value, status = ResolveStatus.from_values(value)) super(origin) @value = value @resolved = (status == ResolveStatus::RESOLVED) # kind of an expensive debug check (makes this constructor pointless) if status != ResolveStatus.from_values(value) raise ConfigBugOrBrokenError, "SimpleConfigList created with wrong resolve status: #{self}" end end
Calls superclass method
Hocon::Impl::AbstractConfigValue::new
Public Instance Methods
Source
# File lib/hocon/impl/simple_config_list.rb, line 329 def <<(e) raise we_are_immutable("<<") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 168 def ==(other) # note that "origin" is deliberately NOT part of equality if other.is_a?(self.class) # optimization to avoid unwrapped() for two ConfigList can_equal(other) && (value.equal?(other.value) || (value == other.value)) else false end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 321 def []=(index, element) raise we_are_immutable("[]=") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 277 def add(e) raise we_are_immutable("add") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 285 def add_all(c) raise we_are_immutable("add_all") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 289 def add_all_at(index, c) raise we_are_immutable("add_all_at") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 281 def add_at(index, element) raise we_are_immutable("add_at") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 164 def can_equal(other) other.is_a?(self.class) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 293 def clear raise we_are_immutable("clear") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 337 def concatenate(other) combined_origin = Hocon::Impl::SimpleConfigOrigin.merge_two_origins(origin, other.origin) combined = value + other.value Hocon::Impl::SimpleConfigList.new(combined_origin, combined) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 231 def contains?(o) value.include?(o) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 239 def contains_all?(c) include_all?(c) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 305 def delete(o) raise we_are_immutable("delete") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 243 def get(index) value[index] end
Source
# File lib/hocon/impl/simple_config_list.rb, line 61 def has_descendant?(descendant) Hocon::Impl::AbstractConfigValue.has_descendant_in_list?(@value, descendant) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 179 def hash # note that "origin" is deliberately NOT part of equality value.hash end
Source
# File lib/hocon/impl/simple_config_list.rb, line 235 def include_all?(value_list) value_list.all? { |v| @value.include?(v)} end
Source
# File lib/hocon/impl/simple_config_list.rb, line 247 def index_of(o) value.index(o) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 258 def last_index_of(o) value.rindex(o) end
Skipping upstream definition of “iterator”, because that’s not really a thing in Ruby.
Source
# File lib/hocon/impl/simple_config_list.rb, line 65 def modify(modifier, new_resolve_status) begin modify_may_throw(modifier, new_resolve_status) rescue Hocon::ConfigError => e raise e end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 73 def modify_may_throw(modifier, new_resolve_status) # lazy-create for optimization changed = nil i = 0 @value.each { |v| modified = modifier.modify_child_may_throw(nil, v) # lazy-create the new list if required if changed == nil && !modified.equal?(v) changed = [] j = 0 while j < i changed << @value[j] j += 1 end end # once the new list is created, all elements # have to go in it.if modifyChild returned # null, we drop that element. if changed != nil && modified != nil changed << modified end i += 1 } if changed != nil if new_resolve_status != nil self.class.new(origin, changed, new_resolve_status) else self.class.new(origin, changed) end else self end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 333 def new_copy(origin) Hocon::Impl::SimpleConfigList.new(origin, @value) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 325 def push(e) raise we_are_immutable("push") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 149 def relativized(prefix) modifier = Class.new do include Hocon::Impl::AbstractConfigValue::NoExceptionsModifier # prefix isn't in scope inside of a def, but it is in scope inside of Class.new # so manually define a method that has access to prefix # I feel dirty define_method(:modify_child) do |key, v| v.relativized(prefix) end end modify(modifier.new, resolve_status) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 297 def remove(o) raise we_are_immutable("remove") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 309 def remove_all(c) raise we_are_immutable("remove_all") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 301 def remove_at(i) raise we_are_immutable("remove_at") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 184 def render_value_to_sb(sb, indent_size, at_root, options) if @value.empty? sb << "[]" else sb << "[" if options.formatted? sb << "\n" end @value.each do |v| if options.origin_comments? lines = v.origin.description.split("\n") lines.each do |l| Hocon::Impl::AbstractConfigValue.indent(sb, indent_size + 1, options) sb << "# " sb << l sb << "\n" end end if options.comments? v.origin.comments.each do |comment| sb << "# " sb << comment sb << "\n" end end Hocon::Impl::AbstractConfigValue.indent(sb, indent_size + 1, options) v.render_value_to_sb(sb, indent_size + 1, at_root, options) sb << "," if options.formatted? sb << "\n" end end # couldn't figure out a better way to chop characters off of the end of # the StringIO. This relies on making sure that, prior to returning the # final string, we take a substring that ends at sb.pos. sb.pos = sb.pos - 1 # chop or newline if options.formatted? sb.pos = sb.pos - 1 # also chop comma sb << "\n" Hocon::Impl::AbstractConfigValue.indent(sb, indent_size, options) end sb << "]" end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 51 def replace_child(child, replacement) new_list = replace_child_in_list(@value, child, replacement) if new_list.nil? nil else # we use the constructor flavor that will recompute the resolve status SimpleConfigList.new(origin, new_list) end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 47 def resolve_status ResolveStatus.from_boolean(@resolved) end
Source
# File lib/hocon/impl/simple_config_list.rb, line 125 def resolve_substitutions(context, source) if @resolved return Hocon::Impl::ResolveResult.make(context, self) end if context.is_restricted_to_child # if a list restricts to a child path, then it has no child paths, # so nothing to do. Hocon::Impl::ResolveResult.make(context, self) else begin modifier = ResolveModifier.new(context, source.push_parent(self)) value = modify_may_throw(modifier, context.options.allow_unresolved ? nil : ResolveStatus::RESOLVED) Hocon::Impl::ResolveResult.make(modifier.context, value) rescue NotPossibleToResolve => e raise e rescue RuntimeError => e raise e rescue Exception => e raise ConfigBugOrBrokenError.new("unexpected exception", e) end end end
Source
# File lib/hocon/impl/simple_config_list.rb, line 313 def retain_all(c) raise we_are_immutable("retain_all") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 317 def set(index, element) raise we_are_immutable("set") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 265 def sub_list(from_index, to_index) value[from_index..to_index] end
skipping upstream definitions of “wrapListIterator”, “listIterator”, and “listIterator(int)”, because those don’t really apply in Ruby.
Source
# File lib/hocon/impl/simple_config_list.rb, line 43 def unwrapped @value.map { |v| v.unwrapped } end
Source
# File lib/hocon/impl/simple_config_list.rb, line 39 def value_type Hocon::ConfigValueType::LIST end
Source
# File lib/hocon/impl/simple_config_list.rb, line 273 def we_are_immutable(method) Hocon::Impl::UnsupportedOperationError.new("ConfigList is immutable, you can't call List. '#{method}'") end
Source
# File lib/hocon/impl/simple_config_list.rb, line 345 def with_origin(origin) super(origin) end
Skipping upstream “writeReplace” until we see that we need it for something
Calls superclass method
Hocon::Impl::AbstractConfigValue#with_origin