-
Notifications
You must be signed in to change notification settings - Fork 54
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
When using recurse_over_arrays true, adding and populating hash in an array doesn't work in some cases #29
Comments
Could you provide examples what the expected results are for each of your Options, and how they break down? At present, the way I believe the original purpose of the memoization was to ensure that two accessor method calls will return the same ROS object instead of returning a different one each time. One way of solving Option B would be to subclass Array for use within ROS (to reimplement methods like Another way might be to check the memoized array to see if it contains any hashes that have not been replaced yet. I also suspect that modifications to the memoized array may not show up under certain circumstances when |
@aetherknight, my expectation would be that option B and option C will work without getting a "no method error", so the user can build those structures in a nice object oriented way. Consider a use case where the user constructs ROS without having a json file, but simply one attribute at a time, just as populating another class in an object oriented way. |
I made a change to how the getter works so that it will always recompute the array that might contain ROS objects, and tested it against the 3 use-cases mentioned above. However, it does not modify the underlying hash |
Even when defining the object with recurse_over_arrays set to true, certain ways of filling the data in an array don't work. (the nicer , more object oriented ones)
Option A - works
obj.spec = {}
obj.spec.ports = [{ 'port' => 3000,
'targetPort' => 'http-server',
'protocol' => 'TCP'
}]
Option B - doesn't work
obj.spec = {}
obj.spec.ports = []
obj.spec.ports << { 'port' => 3000,
'targetPort' => 'http-server',
'protocol' => 'TCP'
}
Option C - doesn't work
obj.spec = {}
obj.spec.ports = []
obj.spec.ports[0]= {}
obj.spec.ports[0].port = 3000
The text was updated successfully, but these errors were encountered: