Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases for inputs and outputs #40

Closed
williampollet opened this issue Jun 30, 2021 · 12 comments
Closed

Aliases for inputs and outputs #40

williampollet opened this issue Jun 30, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@williampollet
Copy link
Contributor

williampollet commented Jun 30, 2021

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 ?

@sunny
Copy link
Owner

sunny commented Jun 30, 2021

Do you have an example use-case for that? Could it be solved in plain Ruby by calling alias description aliased_description?

@AnneSottise
Copy link
Collaborator

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

@sunny
Copy link
Owner

sunny commented Jul 1, 2021

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

@sunny
Copy link
Owner

sunny commented Aug 17, 2021

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

@sunny
Copy link
Owner

sunny commented Oct 27, 2021

@williampollet @AnneSottise: would the play_input syntax work for you, do you think?

@williampollet
Copy link
Contributor Author

williampollet commented Oct 29, 2021

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

@sunny
Copy link
Owner

sunny commented Oct 30, 2021

That looks fine to me. Would you care to build a PR for that feature? 🙏🏻

@AnneSottise
Copy link
Collaborator

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?

@williampollet
Copy link
Contributor Author

williampollet commented Jan 11, 2022

@AnneSottise I think that you can open a PR from a forked repo

@sunny sunny added the enhancement New feature or request label Feb 10, 2022
@sunny sunny changed the title [Enhancement] Add aliases to inputs and outputs Aliases for inputs and outputs Feb 10, 2022
@sunny
Copy link
Owner

sunny commented Apr 21, 2022

@AnneSottise Yes you can open a PR directly to the repo from your fork, or you can share a link to a fork 🙏🏻

@yyamanoi1222
Copy link
Contributor

@sunny May I open PR about this issue

@sunny
Copy link
Owner

sunny commented Oct 20, 2022

Hey @yyamanoi1222, sure, go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants