8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed5ff5b commit da45de5Copy full SHA for da45de5
lib/ostruct.rb
@@ -122,11 +122,21 @@ def initialize_copy(orig) # :nodoc:
122
# data.to_h {|name, value| [name.to_s, value.upcase] }
123
# # => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
124
#
125
- def to_h(&block)
126
- if block_given?
127
- @table.to_h(&block)
128
- else
129
- @table.dup
+ if {test: :to_h}.to_h{ [:works, true] }[:works] # RUBY_VERSION < 2.6 compatibility
+ def to_h(&block)
+ if block_given?
+ @table.to_h(&block)
+ else
130
+ @table.dup
131
+ end
132
133
134
135
136
+ @table.map(&block).to_h
137
138
139
140
end
141
142
0 commit comments