Class: Terraspace::Terraform::RemoteState::OutputProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/terraspace/terraform/remote_state/output_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mod, raw, options = {}) ⇒ OutputProxy

Returns a new instance of OutputProxy.



6
7
8
9
# File 'lib/terraspace/terraform/remote_state/output_proxy.rb', line 6

def initialize(mod, raw, options={})
  @mod, @raw, @options = mod, raw, options
  @format = @options[:format]
end

Instance Attribute Details

#optionsObject (readonly)

raw: can be anything: String, Array, Hash, etc options: original options passed by user from the output helper in tfvars



5
6
7
# File 'lib/terraspace/terraform/remote_state/output_proxy.rb', line 5

def options
  @options
end

#rawObject (readonly)

raw: can be anything: String, Array, Hash, etc options: original options passed by user from the output helper in tfvars



5
6
7
# File 'lib/terraspace/terraform/remote_state/output_proxy.rb', line 5

def raw
  @raw
end

Instance Method Details

#to_rubyObject



23
24
25
26
# File 'lib/terraspace/terraform/remote_state/output_proxy.rb', line 23

def to_ruby
  data = @raw.nil? ? mock_or_error : @raw
  @mod.resolved ? data : Unresolved.new
end

#to_sObject

Should always return a String



12
13
14
15
16
17
18
19
20
21
# File 'lib/terraspace/terraform/remote_state/output_proxy.rb', line 12

def to_s
  if @mod.resolved
    # Dont use Unresolved wrapper because Integer get changed to Strings.
    # Want raw value to be used for the to_json call
    value = @raw.nil? ? mock_or_error : @raw
    value.to_json
  else
    Unresolved.new
  end
end