aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/transform_values.rb
diff options
context:
space:
mode:
authorErik Michaels-Ober <sferik@gmail.com>2014-07-12 18:22:43 +0200
committerErik Michaels-Ober <sferik@gmail.com>2014-07-12 18:22:43 +0200
commitf1bad130d0c9bd77c94e43b696adca56c46a66aa (patch)
treefb3e6896c26b6a74d2997cbdc672c223fd3fda34 /activesupport/lib/active_support/core_ext/hash/transform_values.rb
parente167389e1f2fc577e0d3cb645804d012aee2e89d (diff)
downloadrails-f1bad130d0c9bd77c94e43b696adca56c46a66aa.tar.gz
rails-f1bad130d0c9bd77c94e43b696adca56c46a66aa.tar.bz2
rails-f1bad130d0c9bd77c94e43b696adca56c46a66aa.zip
Return an Enumerator if no block is given
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/transform_values.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/transform_values.rb2
1 files changed, 2 insertions, 0 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 cebf9e815a..e9bcce761f 100644
--- a/activesupport/lib/active_support/core_ext/hash/transform_values.rb
+++ b/activesupport/lib/active_support/core_ext/hash/transform_values.rb
@@ -5,6 +5,7 @@ class Hash
# { a: 1, b: 2, c: 3 }.transform_values { |x| x * 2 }
# # => { a: 2, b: 4, c: 6 }
def transform_values
+ return enum_for(:transform_values) unless block_given?
result = self.class.new
each do |key, value|
result[key] = yield(value)
@@ -14,6 +15,7 @@ class Hash
# Destructive +transform_values+
def transform_values!
+ return enum_for(:transform_values!) unless block_given?
each do |key, value|
self[key] = yield(value)
end