You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've come across a possible issue when trying to flatten multiple properties from a nested hash. It works file when I'm only flattening one property, but when a second one is added both no longer work. I've also been able to narrow it down to string keys. If I symbolize the keys, the flattening works as expected. (See last example).
I can work around it by just calling deep_symbolize_keys prior to passing it to the Trash, but that leaves a bit of a code smell. Any input is appreciated.
Sample Class:
class Person < Hashie::Trash
include Hashie::Extensions::IndifferentAccess
include Hashie::Extensions::IgnoreUndeclared
property :first_name, from: :name, transform_with: ->(name) { name['first'] }
property :last_name, from: :name, transform_with: ->(name) { name['last'] }
property :primary_phone, from: :phoneNumbers, transform_with: ->(numbers) { numbers['primary'] }
end
I've come across a possible issue when trying to flatten multiple properties from a nested hash. It works file when I'm only flattening one property, but when a second one is added both no longer work. I've also been able to narrow it down to string keys. If I symbolize the keys, the flattening works as expected. (See last example).
I can work around it by just calling
deep_symbolize_keys
prior to passing it to the Trash, but that leaves a bit of a code smell. Any input is appreciated.Sample Class:
Sample Hash:
Output:
If I symbolize the the top level keys everything works as expected
Output with symbolized keys:
The text was updated successfully, but these errors were encountered: