https://github.com/aetherknight/recursive-open-struct
OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs
https://github.com/aetherknight/recursive-open-struct
Keywords
openstruct-subclass ruby
Keywords from Contributors
activerecord activejob mvc rspec rubygem grape ruby-gem rack rubocop excon
Last synced: about 18 hours ago
JSON representation
Repository metadata
OpenStruct subclass that returns nested hash attributes as RecursiveOpenStructs
- Host: GitHub
- URL: https://github.com/aetherknight/recursive-open-struct
- Owner: aetherknight
- License: other
- Created: 2010-01-12T11:14:06.000Z (almost 16 years ago)
- Default Branch: main
- Last Pushed: 2025-12-05T07:02:55.000Z (19 days ago)
- Last Synced: 2025-12-09T20:47:15.054Z (14 days ago)
- Topics: openstruct-subclass, ruby
- Language: Ruby
- Homepage:
- Size: 196 KB
- Stars: 290
- Watchers: 10
- Forks: 54
- Open Issues: 4
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Authors: AUTHORS.txt
README.md
recursive-open-struct
OpenStruct subclass that returns nested hash attributes as
RecursiveOpenStructs.
Usage
It allows for hashes within hashes to be called in a chain of methods:
ros = RecursiveOpenStruct.new( { wha: { tagoo: 'siam' } } )
ros.wha.tagoo # => 'siam'
Also, if needed, nested hashes can still be accessed as hashes:
ros.wha_as_a_hash # { tagoo: 'siam' }
Optional: Recurse Over Arrays
RecursiveOpenStruct can also optionally recurse across arrays, although you
have to explicitly enable it.
Default behavior:
h = { :somearr => [ { name: 'a'}, { name: 'b' } ] }
ros = RecursiveOpenStruct.new(h)
ros.somearr # => [ { name: 'a'}, { name: 'b' } ]
Enabling recurse_over_arrays:
ros = RecursiveOpenStruct.new(h, recurse_over_arrays: true )
ros.somearr[0].name # => 'a'
ros.somearr[1].name # => 'b'
Optional: Preserve Original Keys
Also, by default it will turn all hash keys into symbols internally:
h = { 'fear' => 'is', 'the' => 'mindkiller' } }
ros = RecursiveOpenStruct.new(h)
ros.to_h # => { fear: 'is', the: 'mindkiller' }
You can preserve the original keys by enabling :preserve_original_keys:
h = { 'fear' => 'is', 'the' => 'mindkiller' } }
ros = RecursiveOpenStruct.new(h, preserve_original_keys: true)
ros.to_h # => { 'fear' => 'is', 'the' => 'mindkiller' }
Optional: Raise error on missing attribute
This option allows to raise an error if you try to call an attribute you didn't specify in hash
h = { 'fear' => 'is', 'the' => 'mindkiller' } }
ros = RecursiveOpenStruct.new(h, raise_on_missing: true)
ros.undefined # => undefined method `undefined' for #<RecursiveOpenStruct fear="is", the="mindkiller">
The default behaviour returns nil
h = { 'fear' => 'is', 'the' => 'mindkiller' } }
ros = RecursiveOpenStruct.new(h)
ros.undefined # => nil
Installation
Available as a gem in rubygems, the default gem repository.
If you use bundler, just add recursive-open-struct to your gemfile :
gem 'recursive-open-struct'
You may also install the gem manually:
gem install recursive-open-struct
Contributing
If you would like to file or fix a bug, or propose a new feature, please review
CONTRIBUTING first.
Supported Ruby Versions
Recursive-open-struct attempts to support just the versions of Ruby that are
still actively maintained. Once a given major/minor version of Ruby no longer
receives patches, they will no longer be supported (but recursive-open-struct
may still work). I usually update the travis.yml file to reflect this when
preparing for a new release or do some other work on recursive-open-struct.
I also try to update recursive-open-struct to support new features in
OpenStruct itself as new versions of Ruby are released. However, I don't
actively monitor the status of this, so a newer feature might not work. If you
encounter such a feature, please file a bug or a PR to fix it, and I will try
to cut a new release of recursive-open-struct quickly.
SemVer Compliance
Rescursive-open-struct follows SemVer
2.0 for its versioning.
Copyright
Copyright (c) 2009-2018, The Recursive-open-struct developers (given in the
file AUTHORS.txt). See LICENSE.txt for details.
Owner metadata
- Name: William (B.J.) Snow Orvis
- Login: aetherknight
- Email:
- Kind: user
- Description:
- Website: https://www.aedifice.org
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/62613?u=d3e4348cb1d930cbe7c622d67055e396597131a5&v=4
- Repositories: 20
- Last ynced at: 2023-04-10T12:01:28.274Z
- Profile URL: https://github.com/aetherknight
GitHub Events
Total
- Watch event: 13
- Issue comment event: 1
- Push event: 1
- Create event: 1
Last Year
- Watch event: 5
- Issue comment event: 1
- Push event: 1
- Create event: 1
Committers metadata
Last synced: 2 days ago
Total Commits: 200
Total Committers: 29
Avg Commits per committer: 6.897
Development Distribution Score (DDS): 0.335
Commits in past year: 6
Committers in past year: 2
Avg Commits per committer in past year: 3.0
Development Distribution Score (DDS) in past year: 0.333
| Name | Commits | |
|---|---|---|
| William (B.J.) Snow Orvis | a****t@g****m | 133 |
| Offirmo | o****t@g****m | 12 |
| fervic | r****o@r****m | 11 |
| David Feldman | d****n@g****m | 6 |
| Kris Dekeyser | k****r@l****e | 5 |
| Maple Ong | m****g@g****m | 3 |
| Tom Chapin | t****n@g****m | 3 |
| Cédric Felizard | c****c@f****r | 2 |
| Hermann Mayer | h****2@g****m | 2 |
| Jean Boussier | j****r@g****m | 2 |
| Sebastian Gaul | s****n@m****m | 2 |
| Thiago Guimaraes | t****r@g****m | 2 |
| Richard Degenne | r****e@g****m | 1 |
| Victor Guzman | v****n@r****m | 1 |
| Ben Langfeld | b****n@l****e | 1 |
| Beni Cherniavsky-Paskin | c****n@r****m | 1 |
| Edward Betts | e****d@4****m | 1 |
| Ewoud Kohl van Wijngaarden | e****d@k****l | 1 |
| Federico Aloi | f****i@g****m | 1 |
| Hartley McGuire | s****l@g****m | 1 |
| Igor Victor | g****a@y****u | 1 |
| Ilya Umanets | i****s@s****m | 1 |
| Joe Rafaniello | j****e@r****m | 1 |
| Matt Culpepper | m****t@c****o | 1 |
| Matthew O'Riordan | m****n@g****m | 1 |
| Pedro Sena | s****o@g****m | 1 |
| Peter Yeremenko | p****o@g****m | 1 |
| Pirate Praveen | p****n@d****g | 1 |
| Richard Degenne | r****b@g****m | 1 |
Committer domains:
- redhat.com: 2
- runawaybit.com: 2
- debian.org: 1
- culpepper.co: 1
- sabiogroup.com: 1
- yandex.ru: 1
- kohlvanwijngaarden.nl: 1
- 4angle.com: 1
- langfeld.me: 1
- mgvmedia.com: 1
- felizard.fr: 1
- gusto.com: 1
- libis.be: 1
Issue and Pull Request metadata
Last synced: 18 days ago
Total issues: 41
Total pull requests: 42
Average time to close issues: 3 months
Average time to close pull requests: 4 months
Total issue authors: 33
Total pull request authors: 35
Average comments per issue: 2.88
Average comments per pull request: 2.76
Merged pull request: 30
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 1
Past year average time to close issues: N/A
Past year average time to close pull requests: 1 day
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 9.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- aetherknight (3)
- abonas (2)
- pravi (2)
- Kris-LIBIS (2)
- Nowaker (2)
- kke (2)
- mculp (2)
- jromigh (1)
- lilith (1)
- kubenstein (1)
- 31piy (1)
- banister (1)
- Richard-Degenne (1)
- agrare (1)
- wildmaples (1)
Top Pull Request Authors
- fervic (4)
- IlyaUmanets (2)
- Kris-LIBIS (2)
- wildmaples (2)
- Richard-Degenne (2)
- pravi (1)
- michaelachrisco (1)
- Nowaker (1)
- aetherknight (1)
- skipkayhil (1)
- akhiln (1)
- Offirmo (1)
- pyeremenko (1)
- jrafanie (1)
- mculp (1)
Top Issue Labels
- bug (5)
- feature (3)
Top Pull Request Labels
Package metadata
- Total packages: 4
-
Total downloads:
- rubygems: 133,474,328 total
- Total docker downloads: 2,977,731,704
- Total dependent packages: 151 (may contain duplicates)
- Total dependent repositories: 1,799 (may contain duplicates)
- Total versions: 68
- Total maintainers: 4
gem.coop: recursive-open-struct
RecursiveOpenStruct is a subclass of OpenStruct. It differs from OpenStruct in that it allows nested hashes to be treated in a recursive fashion. For example: ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } }) ros.a.b # 'c' Also, nested hashes can still be accessed as hashes: ros.a_as_a_hash # { :b => 'c' }
- Homepage: https://github.com/aetherknight/recursive-open-struct
- Documentation: http://www.rubydoc.info/gems/recursive-open-struct/
- Licenses: MIT
- Latest release: 2.1.0 (published 19 days ago)
- Last Synced: 2025-12-21T21:31:09.071Z (2 days ago)
- Versions: 33
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 66,730,782 Total
- Docker Downloads: 1,488,865,852
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Docker downloads count: 0.065%
- Average: 0.12%
- Downloads: 0.417%
- Maintainers (2)
rubygems.org: recursive-open-struct
RecursiveOpenStruct is a subclass of OpenStruct. It differs from OpenStruct in that it allows nested hashes to be treated in a recursive fashion. For example: ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } }) ros.a.b # 'c' Also, nested hashes can still be accessed as hashes: ros.a_as_a_hash # { :b => 'c' }
- Homepage: https://github.com/aetherknight/recursive-open-struct
- Documentation: http://www.rubydoc.info/gems/recursive-open-struct/
- Licenses: MIT
- Latest release: 2.1.0 (published 19 days ago)
- Last Synced: 2025-12-22T10:48:46.204Z (2 days ago)
- Versions: 33
- Dependent Packages: 151
- Dependent Repositories: 1,799
- Downloads: 66,736,892 Total
- Docker Downloads: 1,488,865,852
-
Rankings:
- Docker downloads count: 0.087%
- Dependent packages count: 0.227%
- Downloads: 0.447%
- Dependent repos count: 0.735%
- Average: 1.439%
- Stargazers count: 3.485%
- Forks count: 3.655%
- Maintainers (2)
gem.coop: recursive-open-struct-sd
RecursiveOpenStruct is a subclass of OpenStruct. It differs from OpenStruct in that it allows nested hashes to be treated in a recursive fashion. For example: ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } }) ros.a.b # 'c' Also, nested hashes can still be accessed as hashes: ros.a_as_a_hash # { :b => 'c' } > This is a fork of the original recursive-open-struct > to include a fix for https://github.com/aetherknight/recursive-open-struct/issues/46
- Homepage: http://github.com/aetherknight/recursive-open-struct
- Documentation: http://www.rubydoc.info/gems/recursive-open-struct-sd/
- Licenses: MIT
- Latest release: 1.0.2 (published about 9 years ago)
- Last Synced: 2025-12-20T13:03:18.821Z (4 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 3,327 Total
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 28.412%
- Downloads: 85.237%
- Maintainers (2)
rubygems.org: recursive-open-struct-sd
RecursiveOpenStruct is a subclass of OpenStruct. It differs from OpenStruct in that it allows nested hashes to be treated in a recursive fashion. For example: ros = RecursiveOpenStruct.new({ :a => { :b => 'c' } }) ros.a.b # 'c' Also, nested hashes can still be accessed as hashes: ros.a_as_a_hash # { :b => 'c' } > This is a fork of the original recursive-open-struct > to include a fix for https://github.com/aetherknight/recursive-open-struct/issues/46
- Homepage: http://github.com/aetherknight/recursive-open-struct
- Documentation: http://www.rubydoc.info/gems/recursive-open-struct-sd/
- Licenses: MIT
- Latest release: 1.0.2 (published about 9 years ago)
- Last Synced: 2025-12-20T13:03:18.820Z (4 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 3,327 Total
-
Rankings:
- Stargazers count: 3.212%
- Forks count: 3.308%
- Dependent packages count: 15.706%
- Average: 31.251%
- Dependent repos count: 46.782%
- Downloads: 87.247%
- Maintainers (2)
Dependencies
- bundler >= 0 development
- pry >= 0 development
- rake >= 0 development
- rdoc >= 0 development
- rspec ~> 3.2 development
- simplecov >= 0 development
- actions/checkout v4 composite
- ruby/setup-ruby 943103cae7d3f1bb1e4951d5fcc7928b40e4b742 composite
Score: 30.909152784617017