Sha256: a31f07934146ecab854c41482c70228fb0b847a3bb76f785c652b6462ee01ae8

Contents?: true

Size: 895 Bytes

Versions: 89

Compression:

Stored size: 895 Bytes

Contents

module Terraspace::Terraform::RemoteState
  class OutputProxy
    # raw: can be anything: String, Array, Hash, etc
    # options: original options passed by user from the output helper in tfvars
    attr_reader :raw, :options
    def initialize(mod, raw, options={})
      @mod, @raw, @options = mod, raw, options
      @format = @options[:format]
    end

    # Should always return a String
    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

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

  private
    def mock_or_error
      @options[:mock] || @options[:error]
    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
terraspace-0.5.3 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.2 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.1 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.0 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.4.4 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.4.3 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.4.2 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.4.1 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.4.0 lib/terraspace/terraform/remote_state/output_proxy.rb