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

get rid of a needless step in HashWithIndifferentAccess #1940

Merged
merged 1 commit into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#### Features

* Your contribution here.
* [#1940](https://github.com/ruby-grape/grape/pull/1940): Get rid of a needless step in HashWithIndifferentAccess - [@dnesteryuk](https://github.com/dnesteryuk).
* [#1938](https://github.com/ruby-grape/grape/pull/1938): Add project metadata to the gemspec - [@orien](https://github.com/orien).
* [#1920](https://github.com/ruby-grape/grape/pull/1920): Replace Virtus with dry-types - [@dnesteryuk](https://github.com/dnesteryuk).

Expand Down
3 changes: 2 additions & 1 deletion lib/grape/dsl/inside_route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def should_be_empty_array?(declared_param, passed_children_params)
end

def declared_param_is_array?(declared_param)
route_options_params[declared_param.to_s] && route_options_params[declared_param.to_s][:type] == 'Array'
key = declared_param.to_s
route_options_params[key] && route_options_params[key][:type] == 'Array'
end

def route_options_params
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def mount_in(router)
methods << Grape::Http::Headers::HEAD
end
methods.each do |method|
unless route.request_method.to_s.upcase == method
unless route.request_method == method
route = Grape::Router::Route.new(method, route.origin, route.attributes.to_h)
end
router.append(route.apply(self))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def params_builder
end

def build_params
params = ::ActiveSupport::HashWithIndifferentAccess[rack_params]
params = ::ActiveSupport::HashWithIndifferentAccess.new(rack_params)
params.deep_merge!(grape_routing_args) if env[Grape::Env::GRAPE_ROUTING_ARGS]
# TODO: remove, in Rails 4 or later ::ActiveSupport::HashWithIndifferentAccess converts nested Hashes into indifferent access ones
DeepHashWithIndifferentAccess.deep_hash_with_indifferent_access(params)
params
end
end
end
Expand Down
18 changes: 0 additions & 18 deletions lib/grape/extensions/deep_hash_with_indifferent_access.rb

This file was deleted.

6 changes: 4 additions & 2 deletions lib/grape/router/route.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ def route_path
end

def initialize(method, pattern, **options)
upcased_method = method.to_s.upcase

@suffix = options[:suffix]
@options = options.merge(method: method.to_s.upcase)
@options = options.merge(method: upcased_method)
@pattern = Pattern.new(pattern, **options)
@translator = AttributeTranslator.new(**options, request_method: method.to_s.upcase)
@translator = AttributeTranslator.new(**options, request_method: upcased_method)
end

def exec(env)
Expand Down