Skip to content
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

Allow a node to be renamed #35

Merged
merged 1 commit into from Dec 16, 2014
Merged

Conversation

@packetmonkey
Copy link
Contributor

@packetmonkey packetmonkey commented Dec 4, 2014

This PR will allow you to #rename a node in place. I took a shot at setting up the documentation but it probably needs to be cleaned up. Feel free to let me know if you would like any changes made so that you are happy merging it.

Do note that I made the name attribute read/write as opposed to read. I had to make it writable and add the rename method because updating a node's name also involves updating information on the parent node if it has one. So I added the rename_child method on the parent that will update it's children hash as well as call #name on the child. By separating out the setting of the instance variable and the logic of communicating with the parent, we avoid a stack overflow as a parent updates the name of the child node which then tries to update the children_hash key on the parent, and so on and so on.

Thanks!

@evolve75
Copy link
Owner

@evolve75 evolve75 commented Dec 4, 2014

Thanks Evan,

Will check out the revision later today, and merge in your code. Thanks a lot again!

Anupam

evolve75 added a commit that referenced this pull request Dec 16, 2014
Allow a node to be renamed
@evolve75 evolve75 merged commit 4fe7eba into evolve75:master Dec 16, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@evolve75
Copy link
Owner

@evolve75 evolve75 commented Dec 17, 2014

@packetmonkey, thanks for the patch. I have merged your changes and made a few modifications. You might want to do a pull. The main change I did was to revert name back to a read-only attribute, as otherwise a writable name attribute might cause confusion downstream (since the attribute writer does not really do any checks). Let me know that you think.

@packetmonkey
Copy link
Contributor Author

@packetmonkey packetmonkey commented Dec 17, 2014

It all looks good to me. I have some code using this functionality so I'll use your master instead of my branch and report any problems I stumble across.

The only other thing I noted is I never updated the API-CHANGES.rdoc file with mention of the #rename or #rename_child methods (I also didn't add anything for the #replace! and #replace_with methods from PR #28 ) I added. Should we add references to those there or is that file mostly for breaking changes?

Thanks again

@evolve75
Copy link
Owner

@evolve75 evolve75 commented Dec 17, 2014

Thanks!

You are correct. The API-CHANGES.rdoc file is really for any breaking changes. So no worries. I usually update History.rdoc with any new API updates (and any other changelog like commentary).

@coveralls
Copy link

@coveralls coveralls commented Jun 20, 2016

Coverage Status

Coverage increased (+0.03%) to 98.684% when pulling 08e7461 on packetmonkey:node-rename into 62b1a5a on evolve75:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.