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

Add deep_clone and deep_delete #91

Merged
merged 10 commits into from
Jul 17, 2020
Merged

Add deep_clone and deep_delete #91

merged 10 commits into from
Jul 17, 2020

Conversation

djberg96
Copy link
Contributor

This PR adds the deep_clone and deep_delete methods to the Array and Hash classes.

The implementations were pulled from miq-deep.rb in gems-pending.

Since the deep_clone implementation was identical for both classes, I put them in a single file (enumerable.rb) and extended both classes from there. The idea is not only to avoid duplication, but other Enumerable classes could be easily added in the future as desired.

Part of the cleanup effort at ManageIQ/manageiq-gems-pending#231

@Fryguy
Copy link
Member

Fryguy commented Jul 17, 2020

LGTM to me...can you also update the README?

@djberg96
Copy link
Contributor Author

@Fryguy Done!

Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM... @bdunne if you are good with this feel free to merge.

# h1[:a] # "hello world"
# h2[:a] # "hello"
#
def deep_clone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@djberg96 djberg96 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would putting it there mean that users would have to explicitly include it to use it? I guess I'm not entirely clear on that particular module's approach as compared to the others.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is meant for nested objects like hashes and arrays. It feels a little more specific than all of enumerable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdunne ok, updated.

@miq-bot
Copy link
Member

miq-bot commented Jul 17, 2020

Checked commits https://github.com/djberg96/more_core_extensions/compare/7781fe4acf664e31993e2cb65fdc748b146011ee~...d4f8eaef0e8cbab360d350dad05686c5a735d37c with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
6 files checked, 2 offenses detected

spec/core_ext/hash/deletes_spec.rb

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

Successfully merging this pull request may close these issues.

4 participants