Sha256: 3f99bbcca09de4c233e885c8caa5108506c9732bec7e6bf3bda90ecaaa37412c

Contents?: true

Size: 1.1 KB

Versions: 22

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require_relative '../value_equality'
require_relative 'change'

module RubyTerraform
  module Models
    class OutputChange
      include ValueEquality

      def initialize(name, content)
        @name = name.to_sym
        @content = symbolise_keys(content)
      end

      def name
        @name.to_s
      end

      def change
        Change.new(@content)
      end

      def no_op?
        change.no_op?
      end

      def create?
        change.create?
      end

      def update?
        change.update?
      end

      def delete?
        change.delete?
      end

      def present_before?
        no_op? || update? || delete?
      end

      def present_after?
        no_op? || create? || update?
      end

      def inspect
        to_h.inspect
      end

      def to_h
        { @name => @content }
      end

      def state
        [@name, @content]
      end

      private

      def symbolise_keys(object)
        if object.is_a?(Hash)
          object.to_h { |k, v| [k.to_sym, symbolise_keys(v)] }
        else
          object
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ruby-terraform-1.9.0.pre.2 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.9.0.pre.1 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.13 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.12 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.11 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.10 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.9 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.8 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.7 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.6 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.5 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.4 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.3 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.2 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.8.0.pre.1 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.7.0 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.7.0.pre.19 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.7.0.pre.18 lib/ruby_terraform/models/output_change.rb
ruby-terraform-1.7.0.pre.17 lib/ruby_terraform/models/output_change.rb