class Terraspace::Terraform::RemoteState::OutputProxy

Attributes

options[R]

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

raw[R]

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

Public Class Methods

new(mod, raw, options={}) click to toggle source
# 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

Public Instance Methods

to_ruby() click to toggle source
# 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_s() click to toggle source

Should always return a String

# 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

Private Instance Methods

mock_or_error() click to toggle source
# File lib/terraspace/terraform/remote_state/output_proxy.rb, line 29
def mock_or_error
  @options[:mock] || @options[:error]
end