Project

hash-graft

0.0
No commit activity in last 3 years
No release in over 3 years
Allows to graft one hash onto another. Also implements Hash::get_path('/path/trough/your/structure') and Hash::set_path('change/value/foo/to', 'bar'). See examples on github.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10
~> 3.1
 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 "*".

@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