summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2022-03-29 14:50:42 -0500
committergit <svn-admin@ruby-lang.org>2022-04-01 00:16:49 +0900
commit87517696373cdcf38de2b11d9f2cfbe950e3ef47 (patch)
treed6bf2391d7aff3e8d6ad2d7ad0948415f1fafee7 /lib
parentaf2ab0dd1c899356d9ec38b052f0df0706efb8f9 (diff)
[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
Diffstat (limited to 'lib')
-rw-r--r--lib/ostruct.rb2
1 files changed, 1 insertions, 1 deletions
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