From ac5f585b9a79af0c117ae99d1fdf8d83795c2058 Mon Sep 17 00:00:00 2001 From: Diego Toral Date: Wed, 16 Feb 2022 11:08:57 -0300 Subject: [PATCH] Use pattern matching controller helpers example Previously we had examples using dry-matchers' syntax and it confused some users (including me) who expected examples to "just work" after adding the gem. Updates the example in the controller helpers section to use pattern matching instead. --- docsite/source/index.html.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docsite/source/index.html.md b/docsite/source/index.html.md index 0d6e588..4ee276b 100644 --- a/docsite/source/index.html.md +++ b/docsite/source/index.html.md @@ -188,14 +188,11 @@ Here's a simple usage example how you could access an operation powered by dry-m ```ruby class UsersController < ApplicationController def create - resolve("users.create").(safe_params[:user]) do |m| - m.success do |user| - render json: user - end - - m.failure do |code, errors| - render json: { code: code, errors: errors.to_h }, status: :unprocessable_entity - end + case resolve("users.create").(safe_params[:user]) + in Success[user] + render json: user + in Failure[code, errors] + render json: { code: code, errors: errors.to_h }, status: :unprocessable_entity end end end