Skip to content

Commit

Permalink
Update Defaults documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aldesantis committed Dec 29, 2016
1 parent dfcd498 commit 3f8c482
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions doc/01-sensible-defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 3f8c482

Please sign in to comment.