diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-27 15:30:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 15:30:51 +0900 |
commit | 0d825a65e0cf9208d9c4ac1036bf361b847d89f6 (patch) | |
tree | 5bc3b552b58c2dd204d0a47f53d1cfacac248c74 /activesupport/lib | |
parent | 801ccab22a8efc2611300a14a8b373a43aa0de28 (diff) | |
parent | de9e3238a008f8f20c5beedefb8787b6e51359d0 (diff) | |
download | rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.tar.gz rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.tar.bz2 rails-0d825a65e0cf9208d9c4ac1036bf361b847d89f6.zip |
Merge pull request #30728 from y-yagi/ensure_transform_keys_of_hwida_to_return_hwida
Ensure `HashWithIndifferentAccess#transform_keys` to return `HashWithIndifferentAccess`
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 5 |
1 files changed, 5 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 12291af443..fcc13feb8c 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -306,6 +306,11 @@ module ActiveSupport dup.tap { |hash| hash.transform_values!(*args, &block) } end + def transform_keys(*args, &block) + return to_enum(:transform_keys) unless block_given? + dup.tap { |hash| hash.transform_keys!(*args, &block) } + end + def compact dup.tap(&:compact!) end |