Class: Hocon::Impl::ConfigReference
  
  
  
  
    
      Constant Summary
      collapse
    
    
      
        - NotPossibleToResolve =
          
        
- Hocon::Impl::AbstractConfigValue::NotPossibleToResolve
 
- UnresolvedSubstitutionError =
          
        
- Hocon::ConfigError::UnresolvedSubstitutionError
 
AbstractConfigValue::ConfigBugOrBrokenError, AbstractConfigValue::ConfigImplUtil, AbstractConfigValue::ResolveStatus
  Instance Attribute Summary collapse
  
  
  
  
  #origin
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #at_key, #at_key_with_origin, #at_path, #at_path_with_origin, #construct_delayed_merge, #delay_merge, has_descendant_in_list?, 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, #with_origin
  
  
  
  
  
  
  
  
  
  #at_key, #at_path, #origin, #render, #with_fallback, #with_origin
  
  
  
  
  
  
  
  
  
  #with_fallback
  
  
  
  
  
  
  Constructor Details
  
    
  
  
    #initialize(origin, expr, prefix_length = 0)  ⇒ ConfigReference 
  
  
  
  
    
Returns a new instance of ConfigReference.
   
 
  
  
    | 
18
19
20
21
22 | # File 'lib/hocon/impl/config_reference.rb', line 18
def initialize(origin, expr, prefix_length = 0)
  super(origin)
  @expr = expr
  @prefix_length = prefix_length
end
 | 
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #expr  ⇒ Object  
  
  
  
  
    
Returns the value of attribute expr.
   
 
  
  
    | 
16
17
18 | # File 'lib/hocon/impl/config_reference.rb', line 16
def expr
  @expr
end
 | 
 
    
      
      
      
  
  
    #prefix_length  ⇒ Object  
  
  
  
  
    
Returns the value of attribute prefix_length.
   
 
  
  
    | 
16
17
18 | # File 'lib/hocon/impl/config_reference.rb', line 16
def prefix_length
  @prefix_length
end
 | 
 
    
   
  
    Instance Method Details
    
      
  
  
    #==(other)  ⇒ Object 
  
  
  
  
    | 
115
116
117
118
119
120 | # File 'lib/hocon/impl/config_reference.rb', line 115
def ==(other)
  
  if other.is_a? Hocon::Impl::ConfigReference
    can_equal(other) && @expr == other.expr
  end
end
 | 
 
    
      
  
  
    #can_equal(other)  ⇒ Object 
  
  
  
  
    | 
111
112
113 | # File 'lib/hocon/impl/config_reference.rb', line 111
def can_equal(other)
  other.is_a? Hocon::Impl::ConfigReference
end
 | 
 
    
      
  
  
    #expression  ⇒ Object 
  
  
  
  
    | 
131
132
133 | # File 'lib/hocon/impl/config_reference.rb', line 131
def expression
  @expr
end
 | 
 
    
      
  
  
    #hash  ⇒ Object 
  
  
  
  
    | 
122
123
124
125 | # File 'lib/hocon/impl/config_reference.rb', line 122
def hash
  
  @expr.hash
end
 | 
 
    
      
  
  
    #ignores_fallbacks?  ⇒ Boolean 
  
  
  
  
    | 
97
98
99 | # File 'lib/hocon/impl/config_reference.rb', line 97
def ignores_fallbacks?
  false
end
 | 
 
    
      
  
  
    #new_copy(new_origin)  ⇒ Object 
  
  
  
  
    | 
93
94
95 | # File 'lib/hocon/impl/config_reference.rb', line 93
def new_copy(new_origin)
  Hocon::Impl::ConfigReference.new(new_origin, @expr, @prefix_length)
end
 | 
 
    
      
  
  
    #relativized(prefix)  ⇒ Object 
  
  
  
  
    | 
105
106
107
108
109 | # File 'lib/hocon/impl/config_reference.rb', line 105
def relativized(prefix)
  new_expr = @expr.change_path(@expr.path.prepend(prefix))
  Hocon::Impl::ConfigReference.new(origin, new_expr, @prefix_length + prefix.length)
end
 | 
 
    
      
  
  
    #render_value_to_sb(sb, indent, at_root, options)  ⇒ Object 
  
  
  
  
    | 
127
128
129 | # File 'lib/hocon/impl/config_reference.rb', line 127
def render_value_to_sb(sb, indent, at_root, options)
  sb << @expr.to_s
end
 | 
 
    
      
  
  
    #resolve_status  ⇒ Object 
  
  
  
  
    | 
101
102
103 | # File 'lib/hocon/impl/config_reference.rb', line 101
def resolve_status
  Hocon::Impl::ResolveStatus::UNRESOLVED
end
 | 
 
    
      
  
  
    #resolve_substitutions(context, source)  ⇒ Object 
  
  
  
  
    
ConfigReference should be a firewall against NotPossibleToResolve going further up the stack; it should convert everything to ConfigException. This way it ‘s impossible for NotPossibleToResolve to “escape” since any failure to resolve has to start with a ConfigReference.
   
 
  
  
    | 
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 | # File 'lib/hocon/impl/config_reference.rb', line 32
def resolve_substitutions(context, source)
  new_context = context.add_cycle_marker(self)
  begin
    result_with_path = source.lookup_subst(new_context, @expr, @prefix_length)
    new_context = result_with_path.result.context
    if result_with_path.result.value != nil
      if Hocon::Impl::ConfigImpl.trace_substitution_enabled
        Hocon::Impl::ConfigImpl.trace(
            "recursively resolving #{result_with_path} which was the resolution of #{expr} against #{source}",
            context.depth)
      end
      recursive_resolve_source = Hocon::Impl::ResolveSource.new(
          result_with_path.path_from_root.last, result_with_path.path_from_root)
      if Hocon::Impl::ConfigImpl.trace_substitution_enabled
        Hocon::Impl::ConfigImpl.trace("will recursively resolve against #{recursive_resolve_source}", context.depth)
      end
      result = new_context.resolve(result_with_path.result.value,
                                   recursive_resolve_source)
      v = result.value
      new_context = result.context
    else
      v = nil
    end
  rescue NotPossibleToResolve => e
    if Hocon::Impl::ConfigImpl.trace_substitution_enabled
      Hocon::Impl::ConfigImpl.trace(
          "not possible to resolve #{expr}, cycle involved: #{e.trace_string}", new_context.depth)
    end
    if @expr.optional
      v = nil
    else
      raise UnresolvedSubstitutionError.new(
                origin,
                "#{@expr} was part of a cycle of substitutions involving #{e.trace_string}", e)
    end
  end
  if v == nil && !@expr.optional
    if new_context.options.allow_unresolved
      ResolveResult.make(new_context.remove_cycle_marker(self), self)
    else
      raise UnresolvedSubstitutionError.new(origin, @expr.to_s)
    end
  else
    Hocon::Impl::ResolveResult.make(new_context.remove_cycle_marker(self), v)
  end
end
 | 
 
    
      
  
  
    #unmerged_values  ⇒ Object 
  
  
  
  
    | 
24
25
26 | # File 'lib/hocon/impl/config_reference.rb', line 24
def unmerged_values
  [self]
end
 | 
 
    
      
  
  
    #unwrapped  ⇒ Object 
  
  
  
  
    | 
89
90
91 | # File 'lib/hocon/impl/config_reference.rb', line 89
def unwrapped
  raise not_resolved
end
 | 
 
    
      
  
  
    #value_type  ⇒ Object 
  
  
  
  
    | 
85
86
87 | # File 'lib/hocon/impl/config_reference.rb', line 85
def value_type
  raise not_resolved
end
 |