Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Persist your hashes like this: {:xyz => 123}.save
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Manifest
README
fafood
hash-save.gemspec

README

SUMMARY:
=======
  Saves hash values to the file system.

WHY?:
====

  I was prototyping something and needed to simulate a database in a
simple way and couldn't find anything that I liked.  I wanted to just
say:

{:a => 1}.save

and then recall it later:

Hash.find(:a)
=> 1

  Super simple.  No frills.  Consider this to be the stone hand-axe of
persistence.

LONGER DESCRIPTION:
==================

  Say, you've got a hash like {:a => 1}

  Using this gem, you'll be able to do this:

{:a => 1}.save

  It will create a file in ./data/<key>.

  The contents of the file will be <value>.

  In the above example, you'll have

./data/a

  whose contents when reloaded

Hash.find(:a)
=> 1


USAGE:
=====
require 'hash-save'

* CREATE

{:david => "pizza"}.save

* READ

Hash.find(:david)
=> "pizza"

* UPDATE by overwriting.

{:david => "burgers}.save

  OR

Hash.modify!(:david){|s| s + " and fries"}
# "burgers and fries"

  OR

x = Hash.find(:david)
=> {:david => "pizza"}

x[:david] = "burgers"
=> {:david => "burgers"}

x.save
# ./data/david is overwritten with the new value.


* INCREMENT

{:id => 1}.save

Hash.inc!(:id)
=> {:id => 2}


License
=======
# MIT License.  Enjoy.  :)
Something went wrong with that request. Please try again.