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-2.2.17 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.16 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.15 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.14 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.13 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.12 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.11 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.10 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.9 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.8 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.7 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.6 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.5 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.4 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.3 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.2 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.1 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.2.0 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.1.7 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-2.1.6 lib/terraspace/terraform/remote_state/output_proxy.rb