-
-
Save borisaka/272543e1eac69aa6a56043fae4e4edbc to your computer and use it in GitHub Desktop.
Revisions
-
adz revised this gist
Jan 13, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ 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]) ) } -
adz created this gist
Jan 13, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ 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.with(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