Closed ExplosiveGM closed 1 year ago
I'm not clear on how this is helping. What's the advantage over using compose
inside of execute
?
When you write code this way, you declare all interactions that you will use inside this parent interaction. Moreover you dont repeat code in parameters and make execute clear.
class ParentInteraction
string :arg1
string :arg2
string :arg3
string :arg4
string :arg5
string :arg6
string :arg7
string :arg8
string: arg9
composable(ApplyArg123 %i[arg1 arg2 arg3])
composable(ApplyArg456, %i[arg4 arg5 arg6])
composable(ApplyArg789, %i[arg7 arg8 arg9])
def execute
apply_arg123
apply_arg456
apply_arg789
true
end
end
Now you can compare this code:
class ParentInteraction
string :arg1
string :arg2
string :arg3
string :arg4
string :arg5
string :arg6
string :arg7
string :arg8
string: arg9
def execute
compose(ApplyArg123, arg1: arg1, arg2: arg2, arg3: arg3])
compose(ApplyArg456, arg4: arg4, arg5: arg5, arg6: arg6])
compose(ApplyArg789, arg7: arg7, arg8: arg8, arg9: arg9])
true
end
end
If you dont like composable method. You can create something like this
class ParentInteraction
string :arg1
string :arg2
string :arg3
string :arg4
string :arg5
string :arg6
string :arg7
string :arg8
string: arg9
use_parent_inputs_for(ApplyArg123, %i[arg1 arg2 arg3])
use_parent_inputs_for(ApplyArg456, %i[arg4 arg5 arg6])
use_parent_inputs_for(ApplyArg789, %i[arg7 arg8 arg9])
def execute
#must take params from parent interaction
compose(ApplyArg123)
compose(ApplyArg456)
compose(ApplyArg789)
true
end
end
Or you can do something like this
class ParentInteraction
string :arg1
string :arg2
string :arg3
string :arg4
string :arg5
string :arg6
string :arg7
string :arg8
string: arg9
def execute
#must take params from parent interaction
compose(ApplyArg123, parent_inputs: true)
compose(ApplyArg456, parent_inputs: true)
compose(ApplyArg789, parent_inputs: true)
true
end
end
This will compare ParentInteraction and ChildInteraction and pass attributes with same name
I hope you understand the main idea.
Okay maybe it is not useful probably I can do something like this
class ParentInteraction
string :arg1
string :arg2
string :arg3
string :arg4
string :arg5
string :arg6
string :arg7
string :arg8
string: arg9
def execute
#must take params from parent interaction
compose(ApplyArg123, inputs)
compose(ApplyArg456, inputs)
compose(ApplyArg789, inputs)
true
end
end
This code add method composable. It must be rewrited. It created for showing main idea. Sometimes when you have many composable interactors inside main interactor you want push args by name
It makes execute method clear