Annotating immutable hashes with methods

20 views
Skip to first unread message

Brian Marick

unread,
Jan 15, 2012, 6:51:06 PM1/15/12
to rubyf...@googlegroups.com
I've recently added a somewhat quick-and-dirty immutable hash to the Stunted repository. The interesting thing about it is the support I've added for tacking methods onto various "shapes" of hashes. They let you make the Ruby code that uses them more readable.

Here's a description of the basic methods:

FunctionalHash.make_maker:
A method that lets you build functions that
make hashes "annotated" with methods
that apply to them.

FunctionalHash#become:
Add a module's worth of functions onto
an existing FunctionalHash. The metaphor
I'm going for is that the programmer points
at a hash and says, "That's not any old hash:
that's a ReservationShaped hash."

https://github.com/marick/stunted/wiki/Annotating-immutable-hashes-with-methods

-----
Brian Marick, Artisanal Labrador
Now working at http://path11.com
Contract programming in Ruby and Clojure
Occasional consulting on Agile


Reply all
Reply to author
Forward
0 new messages