1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure #transform_values of HWIDA to return HWIDA

On Ruby 2.4, naitive `Hash#transform_values` is implemented.
`Hash#transform_values` uses an instance of Hash (`rb_hash_new`) to
collect returned values of a block.
For ensuring `#transform_values` of HWIDA to return HWIDA, we should
define `#transform_values` on HWIDA.
This commit is contained in:
yui-knk 2016-10-26 11:18:10 +09:00
parent c0e656fe40
commit c51a9b975f

View file

@ -273,6 +273,11 @@ module ActiveSupport
dup.tap { |hash| hash.reject!(*args, &block) }
end
def transform_values(*args, &block)
return to_enum(:transform_values) unless block_given?
dup.tap { |hash| hash.transform_values!(*args, &block) }
end
# Convert to a regular hash with string keys.
def to_hash
_new_hash = Hash.new