Class: Tataru::Instructions::RescmpInstruction
Overview
compares resource in temp and resource in top
Instance Attribute Summary
#memory
Instance Method Summary
collapse
Methods included from RomReader
#resolve, #resolve_array, #resolve_hash, #resolve_output, #rom
#desc
#execute, expects
Instance Method Details
#compare(current, desired) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/tataru/instructions/rescmp_instruction.rb', line 22
def compare(current, desired)
result = :no_change
desc.mutable_fields.each do |field|
result = :modify if current[field] != desired[field]
end
desc.immutable_fields.each do |field|
result = :recreate if current[field] != desired[field]
end
result
end
|
#run ⇒ Object
9
10
11
12
13
|
# File 'lib/tataru/instructions/rescmp_instruction.rb', line 9
def run
raise 'Not found' unless rom.key? resource_name
update!
end
|
#update! ⇒ Object
15
16
17
18
19
20
|
# File 'lib/tataru/instructions/rescmp_instruction.rb', line 15
def update!
current = memory.hash[:temp][resource_name]
desired = resolve(rom[resource_name])
memory.hash[:update_action][resource_name] = compare(current, desired)
end
|