Aliases for inputs and outputs
Hey @sunny !!!!
Thanks for the great work \o/
@annesottise and I were wondering what were you thinking about adding aliases to inputs and ouputs, such as:
input :description, type: String, default: nil, as: :aliased_description
Wouldn't it be great ?
Do you have an example use-case for that? Could it be solved in plain Ruby by calling alias description aliased_description?
Concrete example!
Nice version:
class PayProject < Actor
input :project, type: Project
play CreatePayout,
...
->(result) { result.owner = result.project },
CreateBankAccount,
CreateTransferToBank
end
Supa dupa nice version ❤️ :
class PayProject < Actor
input :project, type: Project, as: :owner
play CreatePayout,
...
CreateBankAccount,
CreateTransferToBank
end
I think this would require drastically changing how this is built, since now an organiser is not really involved in how children share tasks. Also as: isn’t very explicit in when the value should be changed and how each side is overwritten.
Perhaps there could be some kind of shorthand syntax that would help with this specific case, instead?
For example we could introduce something like:
play CreatePayout,
…
input_rename(owner: :project),
CreateBankAccount,
CreateTransferToBank
Since the word “rename” implies “changing” the previous, maybe this should be a more generic name tied to the fact that we are copying or aliasing inputs. Perhaps prefixing it by “play” would make sense since it makes it clear we use it in that scenario, e.g.:
play CreatePayout,
…
play_input(owner: :project),
CreateBankAccount,
CreateTransferToBank
@williampollet @AnneSottise: would the play_input syntax work for you, do you think?
not bad, but one might find it difficult to understand since we loose the "alias" meaning.
what do you think about alias_input ? (or input_alias ?)
play CreatePayout,
…
alias_input(owner: :project),
CreateBankAccount,
CreateTransferToBank
That looks fine to me. Would you care to build a PR for that feature? 🙏🏻
Hey ! I made a thing or two regarding this issue. Obvisouly, I missed these last comments 🤡
@sunny can I show you what I've done? It's a bit different from what you guys discussed but I'd like to get your opinion. I cannot push any branch on this repo so if you're interested, could you grant me the rights to do so?
@AnneSottise I think that you can open a PR from a forked repo
@AnneSottise Yes you can open a PR directly to the repo from your fork, or you can share a link to a fork 🙏🏻
@sunny May I open PR about this issue
Hey @yyamanoi1222, sure, go for it!