Project

lazyhash

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
add values to a hash with an arbitrary deep of keys
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.5
 Project Readme

LazyHash

Build Status

LazyHash is a simple library to work with lazy hash's, giving you the ability to create key/value pairs with any deep programatically.

Let's give you some examples:

hash = LazyHash.build_hash
LazyHash.add(hash, "en.projects.title", "Main title")
LazyHash.add(hash, "en.ph1", "one paragraph")

hash #=> {"en" => { "projects" => { "title" => "Main title" }, "ph1" => "one paragraph" } }

Marshable hash

Since a lazy hash has a Proc constructor to dinamycaly create nested hash's, it's not marshable. You can use the following method to construct a new hash without a proc:

lazy_hash = LazyHash.build_hash
...
nolazy = LazyHash.no_lazy(lazy_hash)

Now 'nolazy' can be saved into database with marshal. The original hash remains the same. Also note that you won't be able to use LazyHash.add with this new hash 'nolazy'.