actor icon indicating copy to clipboard operation
actor copied to clipboard

Aliases for inputs and outputs

Open williampollet opened this issue 4 years ago • 10 comments

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 ?

williampollet avatar Jun 30 '21 14:06 williampollet

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

sunny avatar Jun 30 '21 16:06 sunny

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

AnneSottise avatar Jul 01 '21 13:07 AnneSottise

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 avatar Jul 01 '21 14:07 sunny

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 avatar Aug 17 '21 20:08 sunny

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

sunny avatar Oct 27 '21 10:10 sunny

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

williampollet avatar Oct 29 '21 15:10 williampollet

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

sunny avatar Oct 30 '21 08:10 sunny

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 avatar Dec 24 '21 14:12 AnneSottise

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

williampollet avatar Jan 11 '22 10:01 williampollet

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

sunny avatar Apr 21 '22 11:04 sunny

@sunny May I open PR about this issue

yyamanoi1222 avatar Oct 19 '22 22:10 yyamanoi1222

Hey @yyamanoi1222, sure, go for it!

sunny avatar Oct 20 '22 11:10 sunny