Class: Tataru::SubroutineCompiler
Overview
a subroutine for handling a resource
Instance Method Summary
collapse
#check_delete_instructions, #commit_delete_instructions, #delete_instructions, #finish_delete_instructions
#check_update_instructions, #commit_update_instructions, #finish_update_instructions, #modify_check_instructions, #modify_instructions, #recreate_check_instructions, #recreate_commit_instructions, #recreate_finish_instructions, #recreate_instructions, #update_instructions
#check_create_instructions, #commit_create_instructions, #create_instructions, #finish_create_instructions
Constructor Details
#initialize(resource_representation, action) ⇒ SubroutineCompiler
Returns a new instance of SubroutineCompiler.
10
11
12
13
|
# File 'lib/tataru/subroutine_compiler.rb', line 10
def initialize(resource_representation, action)
@rrep = resource_representation
@action = action
end
|
Instance Method Details
#base_action ⇒ Object
23
24
25
|
# File 'lib/tataru/subroutine_compiler.rb', line 23
def base_action
@action.to_s.split('_')[1].to_s
end
|
#body_instructions ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/tataru/subroutine_compiler.rb', line 27
def body_instructions
[
:clear,
*inner_instructions,
:return
]
end
|
#call_instruction ⇒ Object
48
49
50
|
# File 'lib/tataru/subroutine_compiler.rb', line 48
def call_instruction
{ call: label }
end
|
#desc ⇒ Object
15
16
17
|
# File 'lib/tataru/subroutine_compiler.rb', line 15
def desc
@rrep.desc
end
|
#inner_instructions ⇒ Object
44
45
46
|
# File 'lib/tataru/subroutine_compiler.rb', line 44
def inner_instructions
send :"#{@action}_instructions"
end
|
#label ⇒ Object
19
20
21
|
# File 'lib/tataru/subroutine_compiler.rb', line 19
def label
"#{@action}_#{@rrep.name}"
end
|
#load_resource_instructions ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/tataru/subroutine_compiler.rb', line 35
def load_resource_instructions
[
{ key: :resource_name },
{ value: @rrep.name },
{ key: :resource_desc },
{ value: @rrep.desc.class.name }
]
end
|