aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús Burgos <jesus@visrez.com>2016-09-15 12:03:00 +0200
committerJesús Burgos <jesus@visrez.com>2016-10-14 14:27:27 +0200
commite84ed4fd17a9e662d1da647c27ebeffa29c94a01 (patch)
tree52c3d4f2a7de2c31011578efade6e37e9fc81537
parent159b774887cfb3d5c862b2b48d24d75b658e47af (diff)
downloadrails-e84ed4fd17a9e662d1da647c27ebeffa29c94a01.tar.gz
rails-e84ed4fd17a9e662d1da647c27ebeffa29c94a01.tar.bz2
rails-e84ed4fd17a9e662d1da647c27ebeffa29c94a01.zip
Use built-in #transform_values when available.
The methods Hash#transform_values and Hash#transform_values! have been implemented in Ruby and they'll be available as part of the standard library. Here's the link to the discussion in Ruby's issue tracker: https://bugs.ruby-lang.org/issues/12512 These methods are implemented in C so they're expected to perform better.
-rw-r--r--activesupport/lib/active_support/core_ext/hash/transform_values.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/transform_values.rb b/activesupport/lib/active_support/core_ext/hash/transform_values.rb
index 7d507ac998..a307996980 100644
--- a/activesupport/lib/active_support/core_ext/hash/transform_values.rb
+++ b/activesupport/lib/active_support/core_ext/hash/transform_values.rb
@@ -16,7 +16,7 @@ class Hash
result[key] = yield(value)
end
result
- end
+ end unless method_defined? :transform_values
# Destructively converts all values using the +block+ operations.
# Same as +transform_values+ but modifies +self+.
@@ -25,5 +25,5 @@ class Hash
each do |key, value|
self[key] = yield(value)
end
- end
+ end unless method_defined? :transform_values!
end