Skip to content

Conversation

koic
Copy link
Contributor

@koic koic commented Jul 30, 2020

This PR supports Thor::CoreExt::HashWithIndifferentAccess#except and prevents breaking changes in Rails upgrades when using options.except(:key) in Thor task.

When Thor is used with Rails (Active Support), the behavior changes as follows.

With Rails 5.2 or lower

h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"bar"=>2}

With Rails 6.0

h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"foo"=>1, "bar"=>2}

This difference behavior is due to the following changes in Rails 6.0.
rails/rails#35771

This PR makes the behavior between Rails 5.2 and Rails 6.0 compatible.

@koic koic force-pushed the support_except branch from c4f14f1 to e00a585 Compare July 30, 2020 03:27
This PR supports `Thor::CoreExt::HashWithIndifferentAccess#except`
and prevents breaking changes in Rails upgrades when using
`options.except(:key)` in Thor task.

When Thor is used with Rails (Active Support), the behavior changes as follows.

## With Rails 5.2 or lower

```ruby
h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"bar"=>2}
```

## With Rails 6.0

```ruby
h = Thor::CoreExt::HashWithIndifferentAccess.new(foo: 1, bar: 2)
h.except(:foo) #=> {"foo"=>1, "bar"=>2}
```

This difference behavior is due to the following changes in Rails 6.0.
rails/rails#35771

This PR makes the behavior between Rails 5.2 and Rails 6.0 compatible.
@koic koic changed the title Support Thor::CoreExt::HashWithIndifferentAccess#except Support Thor::CoreExt::HashWithIndifferentAccess#except for Rails 6.0 Jul 30, 2020
@koic koic force-pushed the support_except branch from e00a585 to 99a15e6 Compare July 30, 2020 03:37
@rafaelfranca rafaelfranca merged commit 011dc48 into rails:master Feb 11, 2021
@koic koic deleted the support_except branch February 12, 2021 00:39
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