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

feature: add except to IndifferntHash #1940

Conversation

santiagorodriguez96
Copy link
Contributor

@santiagorodriguez96 santiagorodriguez96 commented Aug 21, 2023

The method Hash#except was added in Ruby 3.0 so it would be nice that calling except in a Sinatra::IndifferntHash supported the indifferent access that the latter provides – right now, calling except(:a) on Sinatra::IndifferntHash[a: :a] would not filter the a key.

This commits adds indifferent access support to except so that it will exclude the passed key independently if the key is passed as a String or Symbol.

It was added in Ruby 3.0 so it would be nice that calling except in a
`Sinatra::IndifferntHash` supported the indifferent access that the latter
provides – right now, calling `except(:a)` on `Sinatra::IndifferntHash[a: :a]`
would not filter the `a` key.

This commits adds indifferent access support to except so that it will exclude
the passed key independently if the key is passed as a `String` or `Symbol`.
@dentarg dentarg requested a review from a team August 21, 2023 15:53
@santiagorodriguez96 santiagorodriguez96 changed the title feature: add indifferent access support to Hash#except feature: add except to IndifferntHash Aug 21, 2023
lib/sinatra/indifferent_hash.rb Outdated Show resolved Hide resolved
test/indifferent_hash_test.rb Outdated Show resolved Hide resolved
Co-authored-by: Eloy Pérez <ej.perezgomez@gmail.com>
Copy link
Member

@mwpastore mwpastore left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

I think this looks decent and would avoid some incompatibilities.

@epergo epergo merged commit 0889424 into sinatra:main Aug 22, 2023
15 checks passed
@santiagorodriguez96 santiagorodriguez96 deleted the add-indifferent-access-support-for-except branch August 22, 2023 16:00
@dentarg dentarg mentioned this pull request Nov 26, 2023
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.

None yet

4 participants