Merge pull request #37870 from Shopify/revert-binding-access-in-convert-value
Avoid allocating Binding instance in HWIA#convert_value
This commit is contained in:
commit
cf27cfa18b
@ -91,7 +91,7 @@ def self.[](*args)
|
||||
#
|
||||
# This value can be later fetched using either +:key+ or <tt>'key'</tt>.
|
||||
def []=(key, value)
|
||||
regular_writer(convert_key(key), convert_value(value, for: :assignment))
|
||||
regular_writer(convert_key(key), convert_value(value, conversion: :assignment))
|
||||
end
|
||||
|
||||
alias_method :store, :[]=
|
||||
@ -357,7 +357,7 @@ def to_hash
|
||||
set_defaults(_new_hash)
|
||||
|
||||
each do |key, value|
|
||||
_new_hash[key] = convert_value(value, for: :to_hash)
|
||||
_new_hash[key] = convert_value(value, conversion: :to_hash)
|
||||
end
|
||||
_new_hash
|
||||
end
|
||||
@ -367,9 +367,7 @@ def convert_key(key) # :doc:
|
||||
key.kind_of?(Symbol) ? key.to_s : key
|
||||
end
|
||||
|
||||
def convert_value(value, for: nil) # :doc:
|
||||
conversion = binding.local_variable_get(:for)
|
||||
|
||||
def convert_value(value, conversion: nil) # :doc:
|
||||
if value.is_a? Hash
|
||||
if conversion == :to_hash
|
||||
value.to_hash
|
||||
@ -380,7 +378,7 @@ def convert_value(value, for: nil) # :doc:
|
||||
if conversion != :assignment || value.frozen?
|
||||
value = value.dup
|
||||
end
|
||||
value.map! { |e| convert_value(e, for: conversion) }
|
||||
value.map! { |e| convert_value(e, conversion: conversion) }
|
||||
else
|
||||
value
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user