-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AS] XML behavior processing #9965
Comments
Trying to be clear, I mean that the hash: {"name"=>"age", "__content__"=>"25"} should not be eligible as 'become_content'. value.keys.size == 1 && value['__content__'].present? would return _false_, and the hash would be eligible as 'become_hash', giving me the complete hash I want: {"varValue"=>{"name"=>"age", "__content__"=>"25"}} |
makes sense. Maybe it could change to value['type'] == 'file' || (value['__content__'].present? && value.keys.size == 1 ) |
Running the test suite, I got some failures. The method def become_content?(value)
return true if value['type'] == 'file'
return false unless value.has_key?('__content__')
value.keys.size == 1 || value['type'].present?
end However, according the convention, if some XML legacy brings a |
oddly doing something like def become_content?(value)
value['type'] == 'file' || [["type", "encoding", "__content__"] , ["type", "__content__"] , ["__content__"]].include?(value.keys)
end works @rafaelfranca @carlosantoniodasilva thoughts on if above could be a good thing to do? It satisfies all previous conditions and the one that is reported, as also it is easier to understand. If yes, I would go ahead with a PR. |
This issue has been automatically marked as stale because it has not been commented on for at least The resources of the Rails team are limited, and so we are asking for your help. If you can still reproduce this error on the Thank you for all your contributions. |
This issue has been automatically closed because of inactivity. If you can still reproduce this error on the Thank you for all your contributions. |
Scenario
If I have a xml like this:
Running the 'from_xml' we get this:
Code
.activesupport/lib/active_support/core_ext/hash/conversions.rb
When the hash is being processed, this:
...is eligible for 'become_content'. Then ASupport ignores the 'name' attribute.
I'd like to get something _like_ this:
Initial solution
I realized a solution for that by changing the OR clause for a AND clause.
From:
To:
Summarize:
But I don't know if this is the proper solution.
What about it?
The text was updated successfully, but these errors were encountered: