Class: Kozo::Operations::Update
Instance Attribute Summary
#resource
Instance Method Summary
collapse
#initialize
Instance Method Details
#apply(state) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/kozo/operations/update.rb', line 9
def apply(state)
resource.update!
state.resources.delete(resource)
state.resources << resource
end
|
#to_s ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kozo/operations/update.rb', line 18
def to_s
l = resource.attribute_names.map(&:length).max || 1
attrs = resource
.attributes
.map { |k, v| " #{resource.changes.key?(k) ? display_symbol : ' '} r.#{k.to_s.ljust(l)} = #{resource.changes.key?(k) ? "#{resource.changes[k].first.as_s.indent(4)[4..]} -> #{v.as_s.indent(4)[4..]}" : v.as_s.indent(4)[4..]}" }
.join("\n")
<<~DSL.chomp
#{"# #{resource.address}:".bold}
#{display_symbol} resource "#{resource.resource_name}", "#{resource.state_name}" do |r|
#{attrs}
end
DSL
end
|