Add delete_values() and delete_undef_values() functions#166
Add delete_values() and delete_undef_values() functions#166adrienthebo merged 1 commit intopuppetlabs:masterfrom
Conversation
|
Thank you very much for this contribution! However I have some concerns about how widely used this would be. As a general rule of thumb functions added to stdlib should be usable by 75% of the users of the module, and I'm not sure this meets that criteria. It definitely has merit but I think this function would be better suited as a module. How does this sound to you? |
|
I wrote it for Update: do you have a tool/method to measure what would be possible use of new functions? I've seen some measures provided in other pull requests (#161) and wonder how were they obtained? Regarding these functions in separate module - of course I can do this, but I'm just one person with no company/foundation behind me and this code would probably disappear in short time or left unmaintained. |
|
Added |
|
Ah yes, there is the corner case where :undef is magically turned into an empty string. :( Okay, you've convinced me of the necessity of this. I'm going to go through and add some comments on some parts of the implementation that caught my eye. |
There was a problem hiding this comment.
Did you mean delete_values here?
|
Corrected. |
|
This looks like it's about ready to merge, but before I do that would you be willing to squash these changes down to a single commit? |
|
No problem, done. |
|
Did you rebase all of the changes, or just the most recent changes? |
|
All. |
|
There we go, when I commented I didn't see that - perhaps github hadn't updated. |
Add delete_values() and delete_undef_values() functions
|
summary: merged into master in 5544be9, thanks for the contribution! |
Hi,
delete_values()complementsdelete()for hashes - deletion is based on hash values, not keys,delete_undef_values()may be used to filter-out "unset" parameters from hash. It then plays nicely withensure_resource()orcreate_resources()- see motivating example in README.markdown. I leave this pull request if you consider this function useful enough. Tell me if i've reinvented the wheel.Regards.