Class: Hocon::Impl::SimpleConfigObject::ResolveModifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, source) ⇒ ResolveModifier

Returns a new instance of ResolveModifier.



323
324
325
326
327
# File 'lib/hocon/impl/simple_config_object.rb', line 323

def initialize(context, source)
  @context = context
  @source = source
  @original_restrict = context.restrict_to_child
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



320
321
322
# File 'lib/hocon/impl/simple_config_object.rb', line 320

def context
  @context
end

#sourceObject (readonly)

Returns the value of attribute source.



321
322
323
# File 'lib/hocon/impl/simple_config_object.rb', line 321

def source
  @source
end

Instance Method Details

#modify_child_may_throw(key, v) ⇒ Object



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/hocon/impl/simple_config_object.rb', line 329

def modify_child_may_throw(key, v)
   if @context.is_restricted_to_child
    if key == @context.restrict_to_child.first
      remainder = @context.restrict_to_child.remainder
      if remainder != nil
        result = @context.restrict(remainder).resolve(v, @source)
        @context = result.context.unrestricted.restrict(@original_restrict)
        return result.value
      else
        # we don't want to resolve the leaf child
        return v
      end
    else
      # not in the restrictToChild path
      return v
    end
  else
    # no restrictToChild, resolve everything
    result = @context.unrestricted.resolve(v, @source)
    @context = result.context.unrestricted.restrict(@original_restrict)
    result.value
  end
end