Skip to content

Add support for optional param names #56

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

Merged
merged 1 commit into from
Feb 24, 2016

Conversation

JiriChara
Copy link
Contributor

api-pagination uses params[:page] and params[:per_page] to set the current page and per-page options in the controller by default. This commit allows user to actually override those and use their own getters or specify the name of the parameter. So they can use for example params[:page][:number] for current page by default.

No breaking changes (just one more feature)

@JiriChara JiriChara force-pushed the feature/optional-params branch from d7405c0 to f6a27a0 Compare February 23, 2016 17:59
end

define_method "#{method_name}=" do |param|
if param.is_a?(Symbol)
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm I think since params is a HashWithIndifferentAccess (or, in Grape's case, a Hashie::Mash ¯_(ツ)_/¯), a String should also be fine here

@davidcelis
Copy link
Owner

Nice work here, @JiriChara! I really like the solution you came up with. If you could just fix that one issue I mentioned above, I'm more than happy to merge this in

api-pagination is using the params[:page] and params[:per_page]
parameters by default, but it would be better to make that configurable
and that's what this commit is about.
@JiriChara JiriChara force-pushed the feature/optional-params branch from f6a27a0 to b81d36e Compare February 23, 2016 19:32
@JiriChara
Copy link
Contributor Author

Thanks @davidcelis! I am happy to help :-). I have fixed the issue you mentioned.

davidcelis added a commit that referenced this pull request Feb 24, 2016
Add support for optional param names
@davidcelis davidcelis merged commit c5f6e79 into davidcelis:master Feb 24, 2016
@davidcelis
Copy link
Owner

Thanks a ton!

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