{"id":20481179,"url":"https://github.com/vivek-ng/nested_hash_helper","last_synced_at":"2026-05-06T19:37:28.996Z","repository":{"id":56885323,"uuid":"84061617","full_name":"vivek-ng/nested_hash_helper","owner":"vivek-ng","description":"This gem Aims to provide helper methods in dealing with nested Hashes more easily.","archived":false,"fork":false,"pushed_at":"2017-03-08T14:00:36.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-12T05:39:49.117Z","etag":null,"topics":["hash","nested-hashes","params","rails-params","recursion","ruby","ruby-gem","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vivek-ng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-06T10:44:08.000Z","updated_at":"2017-03-18T14:09:03.000Z","dependencies_parsed_at":"2022-08-20T14:31:14.213Z","dependency_job_id":null,"html_url":"https://github.com/vivek-ng/nested_hash_helper","commit_stats":null,"previous_names":["vivek3894/nested_hash_helper"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/vivek-ng/nested_hash_helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-ng%2Fnested_hash_helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-ng%2Fnested_hash_helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-ng%2Fnested_hash_helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-ng%2Fnested_hash_helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivek-ng","download_url":"https://codeload.github.com/vivek-ng/nested_hash_helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivek-ng%2Fnested_hash_helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32032305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hash","nested-hashes","params","rails-params","recursion","ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-11-15T16:07:16.243Z","updated_at":"2026-04-20T04:03:06.611Z","avatar_url":"https://github.com/vivek-ng.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestedHashHelper\n\nNestedHashHelper gem's aim is to make your life easier in dealing with nested hashes . If you have been working with Rails , You must have noted that You are dealing with nested hashes ( like params from the front end) a lot . \n\nThere are various methods added in the official Ruby code to handle nested hashes , but still it lacks lots of common and useful methods . NestedHashHelper aims to help you with those , so that you can deal with hashes easily in your application . \n\nDevelopment has just begun and is active and we will fix bugs , enhance functionality of existing methods and develop new methods in the upcoming version.\n\n## Usage\n\n###1) deep_except(*excluded_keys)\n   \n  This method extends the functionality of except method of ruby hash to nested hash. pass any number of keys to delete them from the hash . Just pass the immediate key and not the entire key path in the hash . \n\n  Syntax \n  ```ruby  \n  a = {:name =\u003e \"vivek\" , :age =\u003e 22}  \n  a.deep_except(:name)  \n  output ==\u003e {:age =\u003e 22}  \n  ```  \n\n  ```ruby  \n  a = {:user =\u003e {:name =\u003e \"vivek\" , :age =\u003e 22 , :phone =\u003e 3333}}  \n  a.deep_except(:phone , :age)  \n  output ==\u003e {:user =\u003e {:name =\u003e \"vivek\"}}  \n  ```  \n\n\n\n### 2) deep_delete_empty\n   \n   This method deletes all the keys whose value is either empty or nil .\n\n  Syntax   \n   ```ruby  \n   a =  {:user =\u003e {:name =\u003e \"\" , :age =\u003e 22 , :phone =\u003e 3333}}    \n   a.deep_delete_empty  \n   output ==\u003e {:user =\u003e {:age =\u003e 22 , :phone =\u003e 3333}}  \n   ```  \n\n\n### 3) find_depth\n\n   This method finds the depth of your nested hash.\n\n  Syntax   \n  ```ruby  \n  a = {:user =\u003e {:name =\u003e {:last_name =\u003e \"Vivek\"}}}  \n  a.find_depth  \n  output ==\u003e 3  \n  ```  \n\n\n### 4) find_deep_intersection\n\n  This method returns intersection of two nested Hashes.\n\n   Syntax   \n   ```ruby  \n   a = {:user =\u003e {:name =\u003e \"vivek\" , :age =\u003e 22 , :phone =\u003e 3333}}  \n   b = {:user =\u003e {:name =\u003e \"rakesh\" , :age =\u003e 22 , :phone =\u003e 3333}}  \n   a.find_deep_intersection(b)  \n   output ==\u003e {:user =\u003e {:age =\u003e 22 , :phone =\u003e 3333}}  \n   ```  \n\n### 5) find_deep_keys\n \n  This method return all the parent keys of the corresponding value.\n\n\n  Syntax \n  ```ruby\n   a = {:gh =\u003e {:jj =\u003e {:pop =\u003e \"bbb\" , :olo =\u003e \"ooooo\"}} , :pp =\u003e \"ooooo\"}  \n   a.find_deep_keys(\"ooooo\")  \n   output ==\u003e [:gh , :jj , :olo]  \n   ```\n\n### 6) hash_to_array\n      This method will convert the given nested hash to an array\n\n      Syntax\n      a =  {:fg =\u003e {:gh =\u003e {:bn =\u003e \"sdjkhds\"} , :jk =\u003e \"\"} , :kl =\u003e {:gh =\u003e \"\" , :jk =\u003e \"sdjkhds\"}}\n      a.hash_to_array\n      output ==\u003e [[:fg, [:gh, [:bn, \"sdjkhds\"]], [:jk, \"\"]], [:kl, [:gh, \"\"], [:jk, \"sdjkhds\"]]]\n\n      a = {:fg =\u003e {:gh =\u003e {:bn =\u003e \"\"}} , :kl =\u003e{:jk =\u003e \"nnnnnnn\"}}\n      a.hash_to_array\n      output ==\u003e [[:fg, [:gh, [:bn, \"\"]]], [:kl, [:jk, \"nnnnnnn\"]]]  \n\n### 7) deep_delete(key)\n    This method is used to delete a key in a nested hash\n     \n     Syntax\n        a = {:fg =\u003e {:gh =\u003e {:bn =\u003e \"sdjkhds\"} , :bn =\u003e \"\"} , :kl =\u003e {:gh =\u003e \"\" , :jk =\u003e \"sdjkhds\"}}\n        a.deep_delete(:gh)\n        output ==\u003e {:fg=\u003e{:bn=\u003e\"\"}, :kl=\u003e{:jk=\u003e\"sdjkhds\"}}   \n\n### 8) find_all_values(key)\n     This method is used to find all the values of a given key \n\n     Syntax  \n      data = {:students =\u003e {:a =\u003e{:name =\u003e \"vivek\"} , :b=\u003e{:name =\u003e \"rakesh\"}}}\n      data.find_all_values(:name)\n      output ==\u003e [\"vivek\" , \"rakesh\"]\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'nested_hash_helper'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install nested_hash_helper\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nDo Contribute if you come across any bugs / any important feature you feel is essential.\n\nBug reports and pull requests are welcome on GitHub at https://github.com/vivek3894/nested_hash_helper.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivek-ng%2Fnested_hash_helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivek-ng%2Fnested_hash_helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivek-ng%2Fnested_hash_helper/lists"}