Skip to content
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 @@ -12,6 +12,7 @@
* [#2643](https://github.com/ruby-grape/grape/pull/2638): Remove `try` method in codebase - [@ericproulx](https://github.com/ericproulx).
* [#2646](https://github.com/ruby-grape/grape/pull/2646): Call `valid_encoding?` before scrub - [@ericproulx](https://github.com/ericproulx).
* [#2644](https://github.com/ruby-grape/grape/pull/2644): Clean useless/not valuable dependencies - [@ericproulx](https://github.com/ericproulx).
* [#2648](https://github.com/ruby-grape/grape/pull/2648): Remove deprecated ParamsBuilders extensions - [@ericproulx](https://github.com/ericproulx).
* [#2645](https://github.com/ruby-grape/grape/pull/2645): Endpoints are compiled when API is compiled - [@ericproulx](https://github.com/ericproulx).

* Your contribution here.
Expand Down
6 changes: 6 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Upgrading Grape
===============

### Upgrading to >= 3.1

#### ParamsBuilder Grape::Extensions

Deprecated [ParamsBuilder's extensions](https://github.com/ruby-grape/grape/blob/master/UPGRADING.md#params-builder) have been removed.

### Upgrading to >= 3.1.0

#### Enhanced API compile!
Expand Down
1 change: 0 additions & 1 deletion lib/grape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'logger'
require 'active_support'
require 'active_support/concern'
require 'active_support/version'
require 'active_support/isolated_execution_state'
require 'active_support/core_ext/array/conversions' # to_xml
Expand Down

This file was deleted.

27 changes: 0 additions & 27 deletions lib/grape/extensions/hash.rb

This file was deleted.

24 changes: 0 additions & 24 deletions lib/grape/extensions/hashie/mash.rb

This file was deleted.

21 changes: 2 additions & 19 deletions lib/grape/params_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@ module Grape
module ParamsBuilder
extend Grape::Util::Registry

SHORT_NAME_LOOKUP = {
'Grape::Extensions::Hash::ParamBuilder' => :hash,
'Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder' => :hash_with_indifferent_access,
'Grape::Extensions::Hashie::Mash::ParamBuilder' => :hashie_mash
}.freeze

module_function

def params_builder_for(short_name)
verified_short_name = verify_short_name!(short_name)

raise Grape::Exceptions::UnknownParamsBuilder, verified_short_name unless registry.key?(verified_short_name)

registry[verified_short_name]
end

def verify_short_name!(short_name)
return short_name if short_name.is_a?(Symbol)
raise Grape::Exceptions::UnknownParamsBuilder, short_name unless registry.key?(short_name)

class_name = short_name.name
SHORT_NAME_LOOKUP[class_name].tap do |real_short_name|
Grape.deprecator.warn "#{class_name} has been deprecated. Use short name :#{real_short_name} instead."
end
registry[short_name]
end
end
end
38 changes: 0 additions & 38 deletions spec/grape/extensions/param_builders/hash_spec.rb

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions spec/integration/hashie/hashie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,6 @@

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

describe 'Grape::Extensions::Hashie::Mash::ParamBuilder' do
describe 'deprecation' do
context 'when included' do
subject do
Class.new(Grape::API) do
include Grape::Extensions::Hashie::Mash::ParamBuilder
end
end

let(:message) do
'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
end

it 'raises a deprecation' do
expect(Grape.deprecator).to receive(:warn).with(message).and_raise(ActiveSupport::DeprecationException, :deprecated)
expect { subject }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
end
end

context 'when using class name' do
let(:app) do
Class.new(Grape::API) do
params do
build_with Grape::Extensions::Hashie::Mash::ParamBuilder
end
get
end
end

it 'raises a deprecation' do
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,
:deprecated)
expect { get '/' }.to raise_error(ActiveSupport::DeprecationException, 'deprecated')
end
end
end
end

describe 'Grape::ParamsBuilder::HashieMash' do
describe 'in an endpoint' do
describe '#params' do
Expand Down
Loading