Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b32f7d48
Commit
b32f7d48
authored
Jun 24, 2019
by
Lin Jen-Shin
Committed by
Achilleas Pipinellis
Jun 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add doc for ServiceResponse
parent
7f6de7fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
doc/development/reusing_abstractions.md
doc/development/reusing_abstractions.md
+36
-0
No files found.
doc/development/reusing_abstractions.md
View file @
b32f7d48
...
@@ -127,6 +127,42 @@ Everything in `lib/api`.
...
@@ -127,6 +127,42 @@ Everything in `lib/api`.
Everything that resides in
`app/services`
.
Everything that resides in
`app/services`
.
#### ServiceResponse
Service classes usually have an
`execute`
method, which can return a
`ServiceResponse`
. You can use
`ServiceResponse.success`
and
`ServiceResponse.error`
to return a response in
`execute`
method.
In a successful case:
```
ruby
response
=
ServiceResponse
.
success
(
message:
'Branch was deleted'
)
response
.
success?
# => true
response
.
error?
# => false
response
.
status
# => :success
response
.
message
# => 'Branch was deleted'
```
In a failed case:
```
ruby
response
=
ServiceResponse
.
error
(
message:
'Unsupported operation'
)
response
.
success?
# => false
response
.
error?
# => true
response
.
status
# => :error
response
.
message
# => 'Unsupported operation'
```
An additional payload can also be attached:
```
ruby
response
=
ServiceResponse
.
success
(
payload:
{
issue:
issue
})
response
.
payload
[
:issue
]
# => issue
```
### Finders
### Finders
Everything in
`app/finders`
, typically used for retrieving data from a database.
Everything in
`app/finders`
, typically used for retrieving data from a database.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment