From 3f8c482574025601c01d3c541e15094a7aa4737d Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Thu, 29 Dec 2016 13:25:07 +0100 Subject: [PATCH] Update Defaults documentation --- doc/01-sensible-defaults.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/doc/01-sensible-defaults.md b/doc/01-sensible-defaults.md index ec1376f..bfd6942 100644 --- a/doc/01-sensible-defaults.md +++ b/doc/01-sensible-defaults.md @@ -23,8 +23,28 @@ Your modules and classes would, of course, follow the same structure: `API::V1:: `API::V1::Post::Operation::Create` and so on and so forth. If you adhere to this structure, the gem will be able to locate all of your classes without explicit -configuration (i.e. no `#policy` or `#contract` calls etc.). +configuration (i.e. no `#policy` or `#contract` calls etc.). This will save you a lot of time and is +highly recommended, especially when used in conjunction with the provided CRUD operations. -This will save you a lot of time and is highly recommended, especially when used in conjunction with -the provided CRUD operations. If no policy or contract are specified, then the provided operations -will simply skip the authorization/validation step. +To leverage automatic discovery, include `Pragma::Operation::Defaults` in your operation: + +```ruby +module API + module V1 + module Post + module Operation + class Create < Pragma::Operation::Base + include Pragma::Operation::Defaults + + def call + # You can use `decorate`, `validate` and `authorize` without having to explicitly + # specify the decorator, validator and policy classes. + # + # ... + end + end + end + end + end +end +```