Skip to content

Commit 6fdad1f

Browse files
committed
Remove deprecated params_builder extensions.
1 parent bf90e95 commit 6fdad1f

File tree

10 files changed

+10
-209
lines changed

10 files changed

+10
-209
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [#2643](https://github.com/ruby-grape/grape/pull/2638): Remove `try` method in codebase - [@ericproulx](https://github.com/ericproulx).
1313
* [#2646](https://github.com/ruby-grape/grape/pull/2646): Call `valid_encoding?` before scrub - [@ericproulx](https://github.com/ericproulx).
1414
* [#2644](https://github.com/ruby-grape/grape/pull/2644): Clean useless/not valuable dependencies - [@ericproulx](https://github.com/ericproulx).
15+
* [#2648](https://github.com/ruby-grape/grape/pull/2648): Remove deprecated ParamsBuilders extensions - [@ericproulx](https://github.com/ericproulx).
1516
* Your contribution here.
1617

1718
#### Fixes

UPGRADING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Upgrading Grape
22
===============
33

4+
### Upgrading to >= 3.1
5+
6+
#### ParamsBuilder Grape::Extensions
7+
8+
Deprecated [ParamsBuilder's extensions](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md#params-builder) has been removed from the code base.
9+
10+
411
### Upgrading to >= 3.0.0
512

613
#### Ruby 3+ Argument Delegation Modernization

lib/grape.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require 'logger'
44
require 'active_support'
5-
require 'active_support/concern'
65
require 'active_support/version'
76
require 'active_support/isolated_execution_state'
87
require 'active_support/core_ext/array/conversions' # to_xml

lib/grape/extensions/active_support/hash_with_indifferent_access.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/grape/extensions/hash.rb

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/grape/extensions/hashie/mash.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

lib/grape/params_builder.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,12 @@ module Grape
44
module ParamsBuilder
55
extend Grape::Util::Registry
66

7-
SHORT_NAME_LOOKUP = {
8-
'Grape::Extensions::Hash::ParamBuilder' => :hash,
9-
'Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder' => :hash_with_indifferent_access,
10-
'Grape::Extensions::Hashie::Mash::ParamBuilder' => :hashie_mash
11-
}.freeze
12-
137
module_function
148

159
def params_builder_for(short_name)
16-
verified_short_name = verify_short_name!(short_name)
17-
18-
raise Grape::Exceptions::UnknownParamsBuilder, verified_short_name unless registry.key?(verified_short_name)
19-
20-
registry[verified_short_name]
21-
end
22-
23-
def verify_short_name!(short_name)
24-
return short_name if short_name.is_a?(Symbol)
10+
raise Grape::Exceptions::UnknownParamsBuilder, short_name unless registry.key?(short_name)
2511

26-
class_name = short_name.name
27-
SHORT_NAME_LOOKUP[class_name].tap do |real_short_name|
28-
Grape.deprecator.warn "#{class_name} has been deprecated. Use short name :#{real_short_name} instead."
29-
end
12+
registry[short_name]
3013
end
3114
end
3215
end

spec/grape/extensions/param_builders/hash_spec.rb

Lines changed: 0 additions & 38 deletions
This file was deleted.

spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb

Lines changed: 0 additions & 38 deletions
This file was deleted.

spec/integration/hashie/hashie_spec.rb

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,6 @@
55

66
let(:app) { Class.new(Grape::API) }
77

8-
describe 'Grape::Extensions::Hashie::Mash::ParamBuilder' do
9-
describe 'deprecation' do
10-
context 'when included' do
11-
subject do
12-
Class.new(Grape::API) do
13-
include Grape::Extensions::Hashie::Mash::ParamBuilder
14-
end
15-
end
16-
17-
let(:message) do
18-
'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
19-
end
20-
21-
it 'raises a deprecation' do
22-
expect(Grape.deprecator).to receive(:warn).with(message).and_raise(ActiveSupport::DeprecationException, :deprecated)
23-
expect { subject }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
24-
end
25-
end
26-
27-
context 'when using class name' do
28-
let(:app) do
29-
Class.new(Grape::API) do
30-
params do
31-
build_with Grape::Extensions::Hashie::Mash::ParamBuilder
32-
end
33-
get
34-
end
35-
end
36-
37-
it 'raises a deprecation' do
38-
expect(Grape.deprecator).to receive(:warn).with('Grape::Extensions::Hashie::Mash::ParamBuilder has been deprecated. Use short name :hashie_mash instead.').and_raise(ActiveSupport::DeprecationException,
39-
:deprecated)
40-
expect { get '/' }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
41-
end
42-
end
43-
end
44-
end
45-
468
describe 'Grape::ParamsBuilder::HashieMash' do
479
describe 'in an endpoint' do
4810
describe '#params' do

0 commit comments

Comments
 (0)