Sha256: 7e79cc9e5c304c99df3fd019a16abdf889a9391f29ed98d544cd842d3d279c06

Contents?: true

Size: 633 Bytes

Versions: 5

Compression:

Stored size: 633 Bytes

Contents

module Terraspace::Terraform::RemoteState
  class OutputProxy
    # raw: can be anything: String, Array, Hash, etc
    # options: original options passed by user with terraform_output
    attr_reader :raw, :options
    def initialize(raw, options={})
      @raw, @options = raw, options
      @format = @options[:format]
    end

    # Should always return a String
    def to_s
      case @format
      when "string"
        content.to_s
      else # "json"
        content.to_json
      end
    end

    def content
      if @raw.nil?
        @options[:mock] || @options[:error]
      else
        @raw
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
terraspace-0.3.4 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.3.3 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.3.2 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.3.1 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.3.0 lib/terraspace/terraform/remote_state/output_proxy.rb