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.6.10 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.9 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.8 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.7 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.6 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.5 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.4 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.3 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.2 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.1 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.6.0 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.12 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.11 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.10 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.9 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.8 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.7 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.6 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.5 lib/terraspace/terraform/remote_state/output_proxy.rb
terraspace-0.5.4 lib/terraspace/terraform/remote_state/output_proxy.rb