Skip to content

Commit aa41c15

Browse files
committed
Merge pull request #1048 from generalassembly/only-dup-inheritable-values
Only dup InheritableValues, remove support for deep_dup
2 parents 22600cf + bdb334c commit aa41c15

File tree

6 files changed

+12
-158
lines changed

6 files changed

+12
-158
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Next Release
1212
* [#1038](https://github.com/intridea/grape/pull/1038): Avoid dup-ing the String class when used in inherited params - [@rnubel](https://github.com/rnubel).
1313
* [#1042](https://github.com/intridea/grape/issues/1042): Fix coercion of complex arrays - [@dim](https://github.com/dim).
1414
* [#1045](https://github.com/intridea/grape/pull/1045): Do not convert `Rack::Response` to `Rack::Response` in middleware - [@dmitry](https://github.com/dmitry).
15+
* [#1048](https://github.com/intridea/grape/pull/1048): Only dup `InheritableValues`, remove support for `deep_dup` - [@toddmazierski](https://github.com/toddmazierski/)
1516

1617
0.12.0 (6/18/2015)
1718
==================

lib/backports/active_support/deep_dup.rb

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

lib/backports/active_support/duplicable.rb

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

lib/grape.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
require 'set'
1010
require 'active_support/version'
1111
require 'active_support/core_ext/hash/indifferent_access'
12-
13-
if ActiveSupport::VERSION::MAJOR >= 4
14-
require 'active_support/core_ext/object/deep_dup'
15-
else
16-
require_relative 'backports/active_support/deep_dup'
17-
end
18-
require_relative 'backports/active_support/duplicable'
19-
2012
require 'active_support/ordered_hash'
2113
require 'active_support/core_ext/object/conversions'
2214
require 'active_support/core_ext/array/extract_options'

lib/grape/util/inheritable_values.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def to_hash
3636
def initialize_copy(other)
3737
super
3838
self.inherited_values = other.inherited_values
39-
self.new_values = other.new_values.deep_dup
39+
self.new_values = other.new_values.dup
4040
end
4141

4242
protected

spec/grape/util/inheritable_values_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ module Util
6060
end
6161

6262
describe '#clone' do
63-
it 'clones itself even when containing a String class' do
64-
subject[:foo] = String
65-
expect(subject.clone.to_hash).to eq(foo: String)
63+
let(:obj_cloned) { subject.clone }
64+
65+
context 'complex (i.e. not primitive) data types (ex. entity classes, please see bug #891)' do
66+
let(:description) { { entity: double } }
67+
68+
before { subject[:description] = description }
69+
70+
it 'copies values; does not duplicate them' do
71+
expect(obj_cloned[:description]).to eq description
72+
end
6673
end
6774
end
6875
end

0 commit comments

Comments
 (0)