From fc7fa64b0f38ec6222c70eeb7c470e383a7c2e36 Mon Sep 17 00:00:00 2001 From: usa Date: Sat, 25 Mar 2017 16:35:25 +0000 Subject: [PATCH] merge revision(s) 57515: [Backport #13169] lib/ostruct.rb: Fix returned value of each_pair. From a patch by Marcus Stollsteimer. [Fixes #13169] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/ostruct.rb | 1 + test/ostruct/test_ostruct.rb | 1 + version.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index f51eb7b5db..3a1cde4322 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -127,6 +127,7 @@ class OpenStruct def each_pair return to_enum(__method__) { @table.size } unless block_given? @table.each_pair{|p| yield p} + self end # diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 14bc2b2da8..9b76dabeff 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -111,6 +111,7 @@ class TC_OpenStruct < Test::Unit::TestCase def test_each_pair h = {name: "John Smith", age: 70, pension: 300} os = OpenStruct.new(h) + assert_same os, os.each_pair{ } assert_equal '#:each_pair>', os.each_pair.inspect assert_equal [[:name, "John Smith"], [:age, 70], [:pension, 300]], os.each_pair.to_a assert_equal 3, os.each_pair.size diff --git a/version.h b/version.h index 9456b9f39b..32c348455a 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.7" #define RUBY_RELEASE_DATE "2017-03-26" -#define RUBY_PATCHLEVEL 432 +#define RUBY_PATCHLEVEL 433 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3