Skip to content

Commit 625d752

Browse files
committed
Revert Grape.config.param_builder
1 parent e26d7f4 commit 625d752

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,9 @@ end
703703
## Configuration
704704

705705
Use `Grape.configure` to set up global settings at load time.
706+
Currently the configurable settings are:
707+
708+
* `param_builder`: Sets the [Parameter Builder](#parameters), defaults to `Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder`.
706709

707710
To change a setting value make sure that at some point during load time the following code runs
708711

@@ -712,6 +715,17 @@ Grape.configure do |config|
712715
end
713716
```
714717

718+
For example, for the `param_builder`, the following code could run in an initializer:
719+
720+
```ruby
721+
Grape.configure do |config|
722+
config.param_builder = :hashie_mash
723+
end
724+
```
725+
726+
Available parameter builders are `:hash`, `:hash_with_indifferent_access`, and `:hashie_mash`.
727+
See [params_builder](lib/grape/params_builder)
728+
715729
You can also configure a single API:
716730

717731
```ruby

UPGRADING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ Upgrading Grape
33

44
#### Params Builder
55

6-
- Passing a class to `build_with` has been deprecated in favor of a symbolized short_name. See `SHORTNAME_LOOKUP` in [params_builder](lib/grape/params_builder.rb)
6+
- Passing a class to `build_with` or `Grape.config.param_builder` has been deprecated in favor of a symbolized short_name. See `SHORTNAME_LOOKUP` in [params_builder](lib/grape/params_builder.rb)
77
- Including Grape's extensions like `Grape::Extensions::Hashie::Mash::ParamBuilder` has been deprecated in favor of using `build_with` at the route level.
8-
- Grape.configure `param_builder` has been removed in favor using `build_with` at the route level.
98

109
### Upgrading to >= 2.4.0
1110

lib/grape.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ def self.deprecator
6363
@deprecator ||= ActiveSupport::Deprecation.new('2.0', 'Grape')
6464
end
6565

66-
configure(&:compile_methods!)
66+
configure do |config|
67+
config.param_builder = :hash_with_indifferent_access
68+
config.compile_methods!
69+
end
6770
end
6871

6972
# https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html

lib/grape/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Request < Rack::Request
99

1010
def initialize(env, build_params_with: nil)
1111
super(env)
12-
@params_builder = Grape::ParamsBuilder.params_builder_for(build_params_with || DEFAULT_PARAMS_BUILDER)
12+
@params_builder = Grape::ParamsBuilder.params_builder_for(build_params_with || Grape.config.param_builder)
1313
end
1414

1515
def params

0 commit comments

Comments
 (0)