Skip to content

Commit

Permalink
Revert "Maintain subclasses of Hash when calling Hash#slice."
Browse files Browse the repository at this point in the history
This reverts commit 6f291c4.

This I18n original Hash#slice implementation behaves differently from that of Ruby 2.5+
  • Loading branch information
amatsuda committed Oct 27, 2017
1 parent 0a0fa8e commit a3257e4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/i18n/core_ext/hash.rb
@@ -1,6 +1,6 @@
class Hash
def slice(*keep_keys)
h = self.class.new
h = {}
keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
h
end unless Hash.method_defined?(:slice)
Expand All @@ -21,7 +21,7 @@ def deep_symbolize_keys
MERGER = proc do |key, v1, v2|
Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2
end

def deep_merge!(data)
merge!(data, &MERGER)
end unless Hash.method_defined?(:deep_merge!)
Expand Down
6 changes: 0 additions & 6 deletions test/core_ext/hash_test.rb
Expand Up @@ -20,12 +20,6 @@ class I18nCoreExtHashInterpolationTest < I18n::TestCase
assert_equal expected, hash.slice(:foo, :not_here)
end

test "#slice maintains subclasses of Hash" do
klass = Class.new(Hash)
hash = klass[:foo, 'bar', :baz, 'bar']
assert_instance_of klass, hash.slice(:foo)
end

test "#except" do
hash = { :foo => 'bar', :baz => 'bar' }
expected = { :foo => 'bar' }
Expand Down

0 comments on commit a3257e4

Please sign in to comment.