Sha256: 899ff5385e17f9b1d84c35fe7dedaf51669056ce0665a922a06f98749e217bfc

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require_relative 'resource_change'
require_relative 'output_change'

module RubyTerraform
  module Models
    class Plan
      def initialize(content)
        @content = content
      end

      def format_version
        @content[:format_version]
      end

      def terraform_version
        @content[:terraform_version]
      end

      def variables
        @content[:variables]
      end

      def variable_values
        variables.transform_values { |value| value[:value] }
      end

      def resource_changes
        @content[:resource_changes].map do |resource_change|
          ResourceChange.new(resource_change)
        end
      end

      def resource_changes_matching(definition)
        resource_changes.filter do |resource_change|
          definition.all? do |method, value|
            resource_change.send(method) == value
          end
        end
      end

      def output_changes
        @content[:output_changes].map do |output_name, output_change|
          OutputChange.new(output_name, output_change)
        end
      end

      def inspect
        @content.inspect
      end

      def to_h
        @content
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-terraform-1.7.0.pre.10 lib/ruby_terraform/models/plan.rb