Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added shared_params helper #5

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Zawgor24
Copy link
Contributor

@Zawgor24 Zawgor24 commented May 6, 2019

No description provided.

@Zawgor24 Zawgor24 requested a review from stgeneral May 6, 2019 19:48
@Zawgor24 Zawgor24 self-assigned this May 6, 2019
@@ -14,6 +14,7 @@ API is an important part of web applications. They provide interfaces for commun
* Each API resource class (e.g. `UsersResource`) defines a single resource (e.g. `resource :users do ... end`).
* Entities are stored in `entities/` directory and inherited from `Grape::Entity` class.
* Each API resource, entity class or helpers module class are wrapped into corresponding module (e.g. `AppV1API::Resources`, `AppV1API::Entities`, `AppV1API::Helpers`).
* For duplicate params across the project use special `SharedParamsHelper` helper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This sentence is not very English ;)
  2. It is useful for sharing params between several API resources. If params are shared between "actions" of the same resources then it is better to keep them inside the resource.

Probbly, something like this will sound a bit better:
"SharedParamsHelper helper may be used to share params between resources."

extend Grape::API::Helpers

params :user do
# List of API params, for reusing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, is not needed.


resource :user do
params do
use :user # Call `params` which set at SharedParamsHelper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Call -> invokes
  • which set - > which is defined

@stgeneral stgeneral changed the base branch from feature/api-guide-refactoring to develop February 28, 2020 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants