Class: Hocon::Impl::SimpleConfigList
Defined Under Namespace
Classes: ResolveModifier
Constant Summary
collapse
- ResolveStatus =
Hocon::Impl::ResolveStatus
- ResolveResult =
Hocon::Impl::ResolveResult
- ConfigBugOrBrokenError =
Hocon::ConfigError::ConfigBugOrBrokenError
AbstractConfigValue::ConfigImplUtil
Instance Attribute Summary collapse
#origin
Instance Method Summary
collapse
-
#<<(e) ⇒ Object
-
#==(other) ⇒ Object
-
#[]=(index, element) ⇒ Object
-
#add(e) ⇒ Object
-
#add_all(c) ⇒ Object
-
#add_all_at(index, c) ⇒ Object
-
#add_at(index, element) ⇒ Object
-
#can_equal(other) ⇒ Object
-
#clear ⇒ Object
-
#concatenate(other) ⇒ Object
-
#contains?(o) ⇒ Boolean
-
#contains_all?(c) ⇒ Boolean
-
#delete(o) ⇒ Object
-
#get(index) ⇒ Object
-
#has_descendant?(descendant) ⇒ Boolean
-
#hash ⇒ Object
-
#include_all?(value_list) ⇒ Boolean
-
#index_of(o) ⇒ Object
-
#initialize(origin, value, status = ResolveStatus.from_values(value)) ⇒ SimpleConfigList
constructor
A new instance of SimpleConfigList.
-
#is_empty ⇒ Object
-
#last_index_of(o) ⇒ Object
Skipping upstream definition of “iterator”, because that’s not really a thing in Ruby.
-
#modify(modifier, new_resolve_status) ⇒ Object
-
#modify_may_throw(modifier, new_resolve_status) ⇒ Object
-
#new_copy(origin) ⇒ Object
-
#push(e) ⇒ Object
-
#relativized(prefix) ⇒ Object
-
#remove(o) ⇒ Object
-
#remove_all(c) ⇒ Object
-
#remove_at(i) ⇒ Object
-
#render_value_to_sb(sb, indent_size, at_root, options) ⇒ Object
-
#replace_child(child, replacement) ⇒ Object
-
#resolve_status ⇒ Object
-
#resolve_substitutions(context, source) ⇒ Object
-
#retain_all(c) ⇒ Object
-
#set(index, element) ⇒ Object
-
#sub_list(from_index, to_index) ⇒ Object
skipping upstream definitions of “wrapListIterator”, “listIterator”, and “listIterator(int)”, because those don’t really apply in Ruby.
-
#to_array ⇒ Object
-
#unwrapped ⇒ Object
-
#value_type ⇒ Object
-
#we_are_immutable(method) ⇒ Object
-
#with_origin(origin) ⇒ Object
Skipping upstream “writeReplace” until we see that we need it for something.
#at_key, #at_key_with_origin, #at_path, #at_path_with_origin, #construct_delayed_merge, #delay_merge, has_descendant_in_list?, #ignores_fallbacks?, indent, #inspect, #merged_stack_with_non_object, #merged_stack_with_object, #merged_stack_with_the_unmergeable, #merged_with_non_object, #merged_with_object, #merged_with_the_unmergeable, #render, #render_to_sb, replace_child_in_list, #require_not_ignoring_fallbacks, #to_fallback_value, #to_s, #transform_to_string, #with_fallback, #with_fallbacks_ignored
#at_key, #at_path, #origin, #render, #with_fallback
#with_fallback
Constructor Details
#initialize(origin, value, status = ResolveStatus.from_values(value)) ⇒ SimpleConfigList
Returns a new instance of SimpleConfigList.
24
25
26
27
28
29
30
31
32
33
|
# 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)
if status != ResolveStatus.from_values(value)
raise ConfigBugOrBrokenError, "SimpleConfigList created with wrong resolve status: #{self}"
end
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
35
36
37
|
# File 'lib/hocon/impl/simple_config_list.rb', line 35
def value
@value
end
|
Instance Method Details
#<<(e) ⇒ Object
329
330
331
|
# File 'lib/hocon/impl/simple_config_list.rb', line 329
def <<(e)
raise we_are_immutable("<<")
end
|
#==(other) ⇒ Object
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/hocon/impl/simple_config_list.rb', line 168
def ==(other)
if other.is_a?(self.class)
can_equal(other) &&
(value.equal?(other.value) || (value == other.value))
else
false
end
end
|
#[]=(index, element) ⇒ Object
321
322
323
|
# File 'lib/hocon/impl/simple_config_list.rb', line 321
def []=(index, element)
raise we_are_immutable("[]=")
end
|
#add(e) ⇒ Object
277
278
279
|
# File 'lib/hocon/impl/simple_config_list.rb', line 277
def add(e)
raise we_are_immutable("add")
end
|
#add_all(c) ⇒ Object
285
286
287
|
# File 'lib/hocon/impl/simple_config_list.rb', line 285
def add_all(c)
raise we_are_immutable("add_all")
end
|
#add_all_at(index, c) ⇒ Object
289
290
291
|
# File 'lib/hocon/impl/simple_config_list.rb', line 289
def add_all_at(index, c)
raise we_are_immutable("add_all_at")
end
|
#add_at(index, element) ⇒ Object
281
282
283
|
# File 'lib/hocon/impl/simple_config_list.rb', line 281
def add_at(index, element)
raise we_are_immutable("add_at")
end
|
#can_equal(other) ⇒ Object
164
165
166
|
# File 'lib/hocon/impl/simple_config_list.rb', line 164
def can_equal(other)
other.is_a?(self.class)
end
|
#clear ⇒ Object
293
294
295
|
# File 'lib/hocon/impl/simple_config_list.rb', line 293
def clear
raise we_are_immutable("clear")
end
|
#concatenate(other) ⇒ Object
#contains?(o) ⇒ Boolean
231
232
233
|
# File 'lib/hocon/impl/simple_config_list.rb', line 231
def contains?(o)
value.include?(o)
end
|
#contains_all?(c) ⇒ Boolean
239
240
241
|
# File 'lib/hocon/impl/simple_config_list.rb', line 239
def contains_all?(c)
include_all?(c)
end
|
#delete(o) ⇒ Object
305
306
307
|
# File 'lib/hocon/impl/simple_config_list.rb', line 305
def delete(o)
raise we_are_immutable("delete")
end
|
#get(index) ⇒ Object
243
244
245
|
# File 'lib/hocon/impl/simple_config_list.rb', line 243
def get(index)
value[index]
end
|
#has_descendant?(descendant) ⇒ Boolean
#hash ⇒ Object
179
180
181
182
|
# File 'lib/hocon/impl/simple_config_list.rb', line 179
def hash
value.hash
end
|
#include_all?(value_list) ⇒ Boolean
235
236
237
|
# File 'lib/hocon/impl/simple_config_list.rb', line 235
def include_all?(value_list)
value_list.all? { |v| @value.include?(v)}
end
|
#index_of(o) ⇒ Object
247
248
249
|
# File 'lib/hocon/impl/simple_config_list.rb', line 247
def index_of(o)
value.index(o)
end
|
#is_empty ⇒ Object
251
252
253
|
# File 'lib/hocon/impl/simple_config_list.rb', line 251
def is_empty
empty?
end
|
#last_index_of(o) ⇒ Object
Skipping upstream definition of “iterator”, because that’s not really a thing in Ruby.
258
259
260
|
# File 'lib/hocon/impl/simple_config_list.rb', line 258
def last_index_of(o)
value.rindex(o)
end
|
#modify(modifier, new_resolve_status) ⇒ Object
65
66
67
68
69
70
71
|
# 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
|
#modify_may_throw(modifier, new_resolve_status) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/hocon/impl/simple_config_list.rb', line 73
def modify_may_throw(modifier, new_resolve_status)
changed = nil
i = 0
@value.each { |v|
modified = modifier.modify_child_may_throw(nil, v)
if changed == nil && !modified.equal?(v)
changed = []
j = 0
while j < i
changed << @value[j]
j += 1
end
end
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
|
#new_copy(origin) ⇒ Object
333
334
335
|
# File 'lib/hocon/impl/simple_config_list.rb', line 333
def new_copy(origin)
Hocon::Impl::SimpleConfigList.new(origin, @value)
end
|
#push(e) ⇒ Object
325
326
327
|
# File 'lib/hocon/impl/simple_config_list.rb', line 325
def push(e)
raise we_are_immutable("push")
end
|
#relativized(prefix) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/hocon/impl/simple_config_list.rb', line 149
def relativized(prefix)
modifier = Class.new do
include Hocon::Impl::AbstractConfigValue::NoExceptionsModifier
define_method(:modify_child) do |key, v|
v.relativized(prefix)
end
end
modify(modifier.new, resolve_status)
end
|
#remove(o) ⇒ Object
297
298
299
|
# File 'lib/hocon/impl/simple_config_list.rb', line 297
def remove(o)
raise we_are_immutable("remove")
end
|
#remove_all(c) ⇒ Object
309
310
311
|
# File 'lib/hocon/impl/simple_config_list.rb', line 309
def remove_all(c)
raise we_are_immutable("remove_all")
end
|
#remove_at(i) ⇒ Object
301
302
303
|
# File 'lib/hocon/impl/simple_config_list.rb', line 301
def remove_at(i)
raise we_are_immutable("remove_at")
end
|
#render_value_to_sb(sb, indent_size, at_root, options) ⇒ Object
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# 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.
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.
v.origin..each do ||
sb << "# "
sb <<
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
sb.pos = sb.pos - 1 if options.formatted?
sb.pos = sb.pos - 1 sb << "\n"
Hocon::Impl::AbstractConfigValue.indent(sb, indent_size, options)
end
sb << "]"
end
end
|
#replace_child(child, replacement) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# 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
SimpleConfigList.new(origin, new_list)
end
end
|
#resolve_status ⇒ Object
47
48
49
|
# File 'lib/hocon/impl/simple_config_list.rb', line 47
def resolve_status
ResolveStatus.from_boolean(@resolved)
end
|
#resolve_substitutions(context, source) ⇒ Object
#retain_all(c) ⇒ Object
313
314
315
|
# File 'lib/hocon/impl/simple_config_list.rb', line 313
def retain_all(c)
raise we_are_immutable("retain_all")
end
|
#set(index, element) ⇒ Object
317
318
319
|
# File 'lib/hocon/impl/simple_config_list.rb', line 317
def set(index, element)
raise we_are_immutable("set")
end
|
#sub_list(from_index, to_index) ⇒ Object
skipping upstream definitions of “wrapListIterator”, “listIterator”, and “listIterator(int)”, because those don’t really apply in Ruby.
265
266
267
|
# File 'lib/hocon/impl/simple_config_list.rb', line 265
def sub_list(from_index, to_index)
value[from_index..to_index]
end
|
#to_array ⇒ Object
269
270
271
|
# File 'lib/hocon/impl/simple_config_list.rb', line 269
def to_array
value
end
|
#unwrapped ⇒ Object
43
44
45
|
# File 'lib/hocon/impl/simple_config_list.rb', line 43
def unwrapped
@value.map { |v| v.unwrapped }
end
|
#we_are_immutable(method) ⇒ Object
273
274
275
|
# 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
|
#with_origin(origin) ⇒ Object
Skipping upstream “writeReplace” until we see that we need it for something
345
346
347
|
# File 'lib/hocon/impl/simple_config_list.rb', line 345
def with_origin(origin)
super(origin)
end
|