From c0b4db0c28465866b656c894c16ce35f4d313a12 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Wed, 2 Feb 2011 23:35:54 -0500 Subject: fix OrderedHash#each* methods to return Enumerators when called without a block [#6366 state:resolved] Signed-off-by: Santiago Pastorino --- activesupport/lib/active_support/ordered_hash.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index b2f04b427b..fbc40d1b69 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -137,16 +137,19 @@ module ActiveSupport end def each_key + return to_enum(:each_key) unless block_given? @keys.each { |key| yield key } self end def each_value + return to_enum(:each_value) unless block_given? @keys.each { |key| yield self[key]} self end def each + return to_enum(:each) unless block_given? @keys.each {|key| yield [key, self[key]]} self end -- cgit v1.2.3