Class: RubyTerraform::Models::Plan

Inherits:
Object
  • Object
show all
Includes:
ValueEquality
Defined in:
lib/ruby_terraform/models/plan.rb

Instance Method Summary collapse

Methods included from ValueEquality

#==, #hash

Constructor Details

#initialize(content) ⇒ Plan

Returns a new instance of Plan.



12
13
14
# File 'lib/ruby_terraform/models/plan.rb', line 12

def initialize(content)
  @content = symbolise_keys(content)
end

Instance Method Details

#format_versionObject



16
17
18
# File 'lib/ruby_terraform/models/plan.rb', line 16

def format_version
  @content[:format_version]
end

#inspectObject



62
63
64
# File 'lib/ruby_terraform/models/plan.rb', line 62

def inspect
  @content.inspect
end

#output_changesObject



47
48
49
50
51
52
# File 'lib/ruby_terraform/models/plan.rb', line 47

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

#output_changes_matching(definition) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/ruby_terraform/models/plan.rb', line 54

def output_changes_matching(definition)
  output_changes.filter do |output_change|
    definition.all? do |method, value|
      output_change.send(method) == value
    end
  end
end

#resource_changesObject



32
33
34
35
36
37
# File 'lib/ruby_terraform/models/plan.rb', line 32

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

#resource_changes_matching(definition) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/ruby_terraform/models/plan.rb', line 39

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

#stateObject



70
71
72
# File 'lib/ruby_terraform/models/plan.rb', line 70

def state
  [@content]
end

#terraform_versionObject



20
21
22
# File 'lib/ruby_terraform/models/plan.rb', line 20

def terraform_version
  @content[:terraform_version]
end

#to_hObject



66
67
68
# File 'lib/ruby_terraform/models/plan.rb', line 66

def to_h
  @content
end

#variable_valuesObject



28
29
30
# File 'lib/ruby_terraform/models/plan.rb', line 28

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

#variablesObject



24
25
26
# File 'lib/ruby_terraform/models/plan.rb', line 24

def variables
  @content[:variables] || {}
end