Re: Is there a library/mechanism for an object/hash hybrid?
- From: "Rick DeNatale" <rick.denatale@xxxxxxxxx>
- Date: Sat, 31 Mar 2007 08:30:44 +0900
On 3/30/07, dtrusty@xxxxxxxxxxx <dtrusty@xxxxxxxxxxx> wrote:
Hi,
There are times when I want to store items in a hash, and yet refer
the items
using class/object method syntax.
For example, I may want to do this:
myhash['aaa'] = 'bbb'
and then be able to refer to the 'aaa' element either as
myhash['aaa']
--or--
myhash.aaa
I started writing my own class to do this, but I wanted to check to
see if anyone had
already done so.
I just read about this in a blog yesterday:
http://www.oreillynet.com/ruby/blog/2007/03/camping_hashwithreallyindiffer.html
The camping framework has a HashWithIndifferentAccess which does this.
Not to be confused with the class HashWithIndifferentAccess in Rails
(actually in ActiveSupport)
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/
Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
.
- References:
- Is there a library/mechanism for an object/hash hybrid?
- From: dtrusty@xxxxxxxxxxx
- Is there a library/mechanism for an object/hash hybrid?
- Prev by Date: Re: Find the fully qualified name of a class from a string
- Next by Date: Re: What is wrong in my script?
- Previous by thread: Re: Is there a library/mechanism for an object/hash hybrid?
- Next by thread: Send email when a error occurs
- Index(es):
Relevant Pages
|