-
-
Save borisaka/272543e1eac69aa6a56043fae4e4edbc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| command_builder = rom.command # no relation given, so get builder | |
| nested_command = command_builder.create(user: :users) do |user| | |
| user.create(:books) | |
| end | |
| # equivalent: | |
| nested_command = rom.command({user: :users}, [:create, [:books, [:create]]]) | |
| # equivalent | |
| user_create = rom.command(:users)[:create] | |
| books_create = rom.comand(:books)[:create] | |
| nested_command = -> input { | |
| user_create.call(input[:user]).combine( | |
| books_create.call(input[:user][:books]) | |
| ) | |
| } | |
| # and books_create command is built to take (books, user) | |
| # and gets partially applied with :books, so on combine | |
| # it receives output of user_create command, which will be a user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment