diff --git a/CHANGELOG.md b/CHANGELOG.md index 86fc21d13..88c06acba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * [#2725](https://github.com/ruby-grape/grape/pull/2725): Encapsulate `Grape::Validations::Validators::Base` state behind readers; add `required?`/`allow_blank?` predicates - [@ericproulx](https://github.com/ericproulx). * [#2726](https://github.com/ruby-grape/grape/pull/2726): Reuse one `AttributesIterator` per validator and drop the unused `Enumerable` mixin - [@ericproulx](https://github.com/ericproulx). * [#2728](https://github.com/ruby-grape/grape/pull/2728): Deprecate passing a positional options Hash to `auth`/`http_basic`/`http_digest`; pass keyword arguments instead - [@ericproulx](https://github.com/ericproulx). +* [#2733](https://github.com/ruby-grape/grape/pull/2733): Drop the dead `active_support/core_ext/hash/reverse_merge` require; call `ActiveSupport::HashWithIndifferentAccess.new(...)` directly at call sites - [@ericproulx](https://github.com/ericproulx). * Your contribution here. #### Fixes diff --git a/lib/grape.rb b/lib/grape.rb index cab0b054e..bfc59bf8e 100644 --- a/lib/grape.rb +++ b/lib/grape.rb @@ -10,7 +10,7 @@ require 'active_support/core_ext/hash/deep_merge' require 'active_support/core_ext/hash/deep_transform_values' require 'active_support/core_ext/hash/indifferent_access' -require 'active_support/core_ext/hash/reverse_merge' +require 'active_support/hash_with_indifferent_access' require 'active_support/core_ext/module/delegation' # delegate_missing_to require 'active_support/core_ext/object/blank' require 'active_support/core_ext/object/deep_dup' diff --git a/lib/grape/cookies.rb b/lib/grape/cookies.rb index 039bf4c4f..1b0533c95 100644 --- a/lib/grape/cookies.rb +++ b/lib/grape/cookies.rb @@ -40,7 +40,7 @@ def delete(name, **opts) def cookies return @cookies unless @cookies.is_a?(Proc) - @cookies = @cookies.call.with_indifferent_access + @cookies = ActiveSupport::HashWithIndifferentAccess.new(@cookies.call) end def send_cookies diff --git a/lib/grape/middleware/auth/dsl.rb b/lib/grape/middleware/auth/dsl.rb index 7648f4146..eba95211a 100644 --- a/lib/grape/middleware/auth/dsl.rb +++ b/lib/grape/middleware/auth/dsl.rb @@ -9,7 +9,7 @@ def auth(type = nil, *legacy_options, **options, &block) return namespace_inheritable[:auth] unless type options = merge_legacy_auth_options(:auth, legacy_options, options) - namespace_inheritable[:auth] = options.reverse_merge(type: type.to_sym, proc: block) + namespace_inheritable[:auth] = { type: type.to_sym, proc: block }.merge!(options) use Grape::Middleware::Auth::Base, namespace_inheritable[:auth] end diff --git a/lib/grape/middleware/error.rb b/lib/grape/middleware/error.rb index 89b050e29..8dc479786 100644 --- a/lib/grape/middleware/error.rb +++ b/lib/grape/middleware/error.rb @@ -195,7 +195,7 @@ def framework_default(endpoint) def error!(message, status = default_status, headers = {}, backtrace = [], original_exception = nil) env[Grape::Env::API_ENDPOINT].status(status) # not error! inside route - merged_headers = headers.reverse_merge(Rack::CONTENT_TYPE => content_type) + merged_headers = { Rack::CONTENT_TYPE => content_type }.merge!(headers) error = Grape::Exceptions::ErrorResponse.new( status:, message:, headers: merged_headers, backtrace:, original_exception: ) diff --git a/lib/grape/middleware/precomputed_content_types.rb b/lib/grape/middleware/precomputed_content_types.rb index ca6b1f7c4..3677c8310 100644 --- a/lib/grape/middleware/precomputed_content_types.rb +++ b/lib/grape/middleware/precomputed_content_types.rb @@ -38,7 +38,7 @@ def content_type private def content_types_indifferent_access - @content_types_indifferent_access ||= content_types.with_indifferent_access + @content_types_indifferent_access ||= ActiveSupport::HashWithIndifferentAccess.new(content_types) end end end diff --git a/lib/grape/params_builder/hash_with_indifferent_access.rb b/lib/grape/params_builder/hash_with_indifferent_access.rb index cce22fc21..e8bfd3778 100644 --- a/lib/grape/params_builder/hash_with_indifferent_access.rb +++ b/lib/grape/params_builder/hash_with_indifferent_access.rb @@ -4,7 +4,7 @@ module Grape module ParamsBuilder class HashWithIndifferentAccess < Base def self.call(params) - params.with_indifferent_access + ActiveSupport::HashWithIndifferentAccess.new(params) end end end diff --git a/lib/grape/util/registry.rb b/lib/grape/util/registry.rb index 93fabc668..25ed981b0 100644 --- a/lib/grape/util/registry.rb +++ b/lib/grape/util/registry.rb @@ -20,7 +20,7 @@ def build_short_name(klass) end def registry - @registry ||= {}.with_indifferent_access + @registry ||= ActiveSupport::HashWithIndifferentAccess.new end end end