Module: Tataru::UpdateSubroutines

Included in:
SubroutineCompiler
Defined in:
lib/tataru/update_subroutines.rb

Overview

update subroutines

Instance Method Summary collapse

Instance Method Details

#check_update_instructionsObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/tataru/update_subroutines.rb', line 21

def check_update_instructions
  [
    { value_update: @rrep.name },
    { compare: :recreate },
    { goto_if: "recreate_check_#{@rrep.name}" },
    { value_update: @rrep.name },
    { compare: :modify },
    { goto_if: "modify_check_#{@rrep.name}" }
  ]
end

#commit_update_instructionsObject



32
33
34
35
36
37
38
# File 'lib/tataru/update_subroutines.rb', line 32

def commit_update_instructions
  [
    { value_update: @rrep.name },
    { compare: :recreate },
    { goto_if: "recreate_commit_#{@rrep.name}" }
  ]
end

#finish_update_instructionsObject



40
41
42
43
44
45
46
# File 'lib/tataru/update_subroutines.rb', line 40

def finish_update_instructions
  [
    { value_update: @rrep.name },
    { compare: :recreate },
    { goto_if: "recreate_finish_#{@rrep.name}" }
  ]
end

#modify_check_instructionsObject



57
58
59
60
61
62
# File 'lib/tataru/update_subroutines.rb', line 57

def modify_check_instructions
  [
    *load_resource_instructions,
    :check_update
  ]
end

#modify_instructionsObject



48
49
50
51
52
53
54
55
# File 'lib/tataru/update_subroutines.rb', line 48

def modify_instructions
  [
    *load_resource_instructions,
    { key: :properties },
    { value_rom: @rrep.name },
    :update
  ]
end

#recreate_check_instructionsObject



81
82
83
84
85
# File 'lib/tataru/update_subroutines.rb', line 81

def recreate_check_instructions
  [
    *check_create_instructions
  ]
end

#recreate_commit_instructionsObject



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/tataru/update_subroutines.rb', line 87

def recreate_commit_instructions
  return [] unless desc.delete_at_end?

  [
    { key: :resource_name },
    { value: "_deletable_#{@rrep.name}" },
    { key: :resource_desc },
    { value: @rrep.desc.class.name },
    :delete
  ]
end

#recreate_finish_instructionsObject



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/tataru/update_subroutines.rb', line 99

def recreate_finish_instructions
  return [] unless desc.delete_at_end?

  [
    { key: :resource_name },
    { value: "_deletable_#{@rrep.name}" },
    { key: :resource_desc },
    { value: @rrep.desc.class.name },
    :check_delete
  ]
end

#recreate_instructionsObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/tataru/update_subroutines.rb', line 64

def recreate_instructions
  deletion_routine = [
    *load_resource_instructions,
    :mark_deletable
  ]
  unless desc.delete_at_end?
    deletion_routine = [
      *delete_instructions,
      *check_delete_instructions
    ]
  end
  [
    *deletion_routine,
    *create_instructions
  ]
end

#update_instructionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tataru/update_subroutines.rb', line 6

def update_instructions
  [
    *load_resource_instructions,
    :read,
    *load_resource_instructions,
    :rescmp,
    { value_update: @rrep.name },
    { compare: :recreate },
    { goto_if: "recreate_#{@rrep.name}" },
    { value_update: @rrep.name },
    { compare: :modify },
    { goto_if: "modify_#{@rrep.name}" }
  ]
end