From 87517696373cdcf38de2b11d9f2cfbe950e3ef47 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 29 Mar 2022 14:50:42 -0500 Subject: [PATCH] [ruby/ostruct] Avoid using block_given in the presence of aliases defined?(yield) bypasses the block_given? method (or any aliases to it) and always does the right thing. https://github.com/ruby/ostruct/commit/4c38fe612e --- lib/ostruct.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ostruct.rb b/lib/ostruct.rb index efe5f4fe37..c5d22dc8a2 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -197,7 +197,7 @@ class OpenStruct # data.each_pair.to_a # => [[:country, "Australia"], [:capital, "Canberra"]] # def each_pair - return to_enum(__method__) { @table.size } unless block_given! + return to_enum(__method__) { @table.size } unless defined?(yield) @table.each_pair{|p| yield p} self end