[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
This commit is contained in:
parent
af2ab0dd1c
commit
8751769637
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user