https://github.com/hoodie/hash-graft
transforms hashes from one into another form following certain rules
https://github.com/hoodie/hash-graft
Last synced: about 1 month ago
JSON representation
transforms hashes from one into another form following certain rules
- Host: GitHub
- URL: https://github.com/hoodie/hash-graft
- Owner: hoodie
- License: gpl-2.0
- Created: 2014-11-06T22:34:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-15T21:35:20.000Z (over 10 years ago)
- Last Synced: 2025-03-10T15:16:51.182Z (2 months ago)
- Language: Ruby
- Size: 172 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
HashGraft
=========## Hash/Array Mixins
adds get_path(path) and set_path(path, value) to Hash.
Allows to traverse deeply nested data structures similar to structures.Arrays also validate a wildcard "*".
``` {.ruby}
@example_1 = {
"guys" => [
{"name" => "Dean"},
{"name" => "Sal"},
{"name" => "Carlo"},
],
"gals" => [
{"name" => "Marylou"},
{"name" => "Camilly"},
{"name" => "Terry"},
{"name" => "Mary"},
{"name" => "Rita"},
{"name" => "Amy"},
]}@example_1.get_path "gals/2/name" # => "Terry"
@example_1.get_path("gals/*/name") # => ["Marylou","Camilly","Terry","Mary","Rita","Amy"]@example_1.graft(@example_1) # => nothing changes
```
## Transformer
uses get_path/set_path to transform one data structure into another.
*examples will follow*