Sha256: 4d948a4c4dcd61e0efdf97644cb1e267f09b711c44c612567542910d735959d8

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 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 output_changes_matching(definition)
        output_changes.filter do |output_change|
          definition.all? do |method, value|
            output_change.send(method) == value
          end
        end
      end

      def inspect
        @content.inspect
      end

      def to_h
        @content
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-terraform-1.7.0.pre.13 lib/ruby_terraform/models/plan.rb
ruby-terraform-1.7.0.pre.12 lib/ruby_terraform/models/plan.rb
ruby-terraform-1.7.0.pre.11 lib/ruby_terraform/models/plan.rb