{"id":13877897,"url":"https://github.com/aetherknight/recursive-open-struct","last_synced_at":"2025-05-14T22:09:07.604Z","repository":{"id":777720,"uuid":"468685","full_name":"aetherknight/recursive-open-struct","owner":"aetherknight","description":"OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs","archived":false,"fork":false,"pushed_at":"2024-10-04T05:53:40.000Z","size":189,"stargazers_count":291,"open_issues_count":4,"forks_count":54,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-04T10:01:46.383Z","etag":null,"topics":["openstruct-subclass","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jacobrask/styledocco","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aetherknight.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-01-12T11:14:06.000Z","updated_at":"2025-04-03T13:23:37.000Z","dependencies_parsed_at":"2024-06-02T21:26:56.707Z","dependency_job_id":"31735671-f1f1-41b3-ab92-4bb8584a7c96","html_url":"https://github.com/aetherknight/recursive-open-struct","commit_stats":{"total_commits":194,"total_committers":28,"mean_commits":6.928571428571429,"dds":0.3350515463917526,"last_synced_commit":"d26b6e88135ec54e44a0b4efd48743469f242b7a"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aetherknight%2Frecursive-open-struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aetherknight%2Frecursive-open-struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aetherknight%2Frecursive-open-struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aetherknight%2Frecursive-open-struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aetherknight","download_url":"https://codeload.github.com/aetherknight/recursive-open-struct/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253418941,"owners_count":21905334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["openstruct-subclass","ruby"],"created_at":"2024-08-06T08:01:34.361Z","updated_at":"2025-05-14T22:09:07.565Z","avatar_url":"https://github.com/aetherknight.png","language":"Ruby","readme":"# recursive-open-struct\n\nOpenStruct subclass that returns nested hash attributes as\nRecursiveOpenStructs.\n\n\n## Usage\n\nIt allows for hashes within hashes to be called in a chain of methods:\n\n```ruby\nros = RecursiveOpenStruct.new( { wha: { tagoo: 'siam' } } )\n\nros.wha.tagoo # =\u003e 'siam'\n```\n\nAlso, if needed, nested hashes can still be accessed as hashes:\n\n```ruby\nros.wha_as_a_hash # { tagoo: 'siam' }\n```\n\n\n### Optional: Recurse Over Arrays\n\nRecursiveOpenStruct can also optionally recurse across arrays, although you\nhave to explicitly enable it.\n\nDefault behavior:\n```ruby\nh = { :somearr =\u003e [ { name: 'a'}, { name: 'b' } ] }\n\nros = RecursiveOpenStruct.new(h)\nros.somearr # =\u003e [ { name: 'a'}, { name: 'b' } ]\n```\n\nEnabling `recurse_over_arrays`:\n\n```ruby\nros = RecursiveOpenStruct.new(h, recurse_over_arrays: true )\n\nros.somearr[0].name # =\u003e 'a'\nros.somearr[1].name # =\u003e 'b'\n```\n\n\n### Optional: Preserve Original Keys\n\nAlso, by default it will turn all hash keys into symbols internally:\n\n```ruby\nh = { 'fear' =\u003e 'is', 'the' =\u003e 'mindkiller' } }\nros = RecursiveOpenStruct.new(h)\nros.to_h # =\u003e { fear: 'is', the: 'mindkiller' }\n```\n\nYou can preserve the original keys by enabling `:preserve_original_keys`:\n\n```ruby\nh = { 'fear' =\u003e 'is', 'the' =\u003e 'mindkiller' } }\nros = RecursiveOpenStruct.new(h, preserve_original_keys: true)\nros.to_h # =\u003e { 'fear' =\u003e 'is', 'the' =\u003e 'mindkiller' }\n```\n\n### Optional: Raise error on missing attribute\n\nThis option allows to raise an error if you try to call an attribute you didn't specify in hash\n\n```ruby\nh = { 'fear' =\u003e 'is', 'the' =\u003e 'mindkiller' } }\nros = RecursiveOpenStruct.new(h, raise_on_missing: true)\nros.undefined # =\u003e undefined method `undefined' for #\u003cRecursiveOpenStruct fear=\"is\", the=\"mindkiller\"\u003e\n```\n\nThe default behaviour returns nil\n\n```ruby\nh = { 'fear' =\u003e 'is', 'the' =\u003e 'mindkiller' } }\nros = RecursiveOpenStruct.new(h)\nros.undefined # =\u003e nil\n```\n\n## Installation\n\nAvailable as a gem in rubygems, the default gem repository.\n\nIf you use bundler, just add recursive-open-struct to your gemfile :\n\n```ruby\ngem 'recursive-open-struct'\n```\n\nYou may also install the gem manually:\n\n    gem install recursive-open-struct\n\n\n## Contributing\n\nIf you would like to file or fix a bug, or propose a new feature, please review\n[CONTRIBUTING](CONTRIBUTING.md) first.\n\n\n## Supported Ruby Versions\n\nRecursive-open-struct attempts to support just the versions of Ruby that are\nstill actively maintained. Once a given major/minor version of Ruby no longer\nreceives patches, they will no longer be supported (but recursive-open-struct\nmay still work). I usually update the travis.yml file to reflect this when\npreparing for a new release or do some other work on recursive-open-struct.\n\nI also try to update recursive-open-struct to support new features in\nOpenStruct itself as new versions of Ruby are released. However, I don't\nactively monitor the status of this, so a newer feature might not work. If you\nencounter such a feature, please file a bug or a PR to fix it, and I will try\nto cut a new release of recursive-open-struct quickly.\n\n\n## SemVer Compliance\n\nRescursive-open-struct follows [SemVer\n2.0](https://semver.org/spec/v2.0.0.html) for its versioning.\n\n\n## Copyright\n\nCopyright (c) 2009-2018, The Recursive-open-struct developers (given in the\nfile AUTHORS.txt). See LICENSE.txt for details.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faetherknight%2Frecursive-open-struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faetherknight%2Frecursive-open-struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faetherknight%2Frecursive-open-struct/lists"}