aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-12-17 19:15:09 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-01-06 17:49:18 +0900
commitd97ba3447268f6c72ca545221a22714641d98325 (patch)
tree857c31f6e898ac65c92647272d9bf794d2e8f020 /activesupport/lib/active_support
parentb1df82e41275e781fee4dd79264c95c3f21fad6d (diff)
downloadrails-d97ba3447268f6c72ca545221a22714641d98325.tar.gz
rails-d97ba3447268f6c72ca545221a22714641d98325.tar.bz2
rails-d97ba3447268f6c72ca545221a22714641d98325.zip
ensure `#compact` of HWIDA to return HWIDA
`Hash#compact` of Ruby native returns new hash. Therefore, in order to return HWIDA as in the past version, need to define own `#compact` to HWIDA. Related: #26868
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index d3f7b46e77..79e7feaf47 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -269,6 +269,10 @@ module ActiveSupport
dup.tap { |hash| hash.transform_values!(*args, &block) }
end
+ def compact
+ dup.compact!
+ end
+
# Convert to a regular hash with string keys.
def to_hash
_new_hash = Hash.new