putting away HashWithIndifferentAccess

MenTaLguY mental at rydia.net
Tue Sep 25 18:42:00 EDT 2007


On Tue, 25 Sep 2007 17:26:37 -0500, why the lucky stiff <why at whytheluckystiff.net> wrote:

> I'm not too hot on [symbol] and [string] equivalence.  But I do like
> to call the query string vars like methods.  What do you think about
> using OpenStruct instead?
> 
> I've been testing with this:
> 
>   class H < OpenStruct
>     def u h;for k,v in h;@table[k.to_sym]=v;new_ostruct_member(k);end
>     def self.[] *a;new *a;end
>   en
> 
> Or, you know, just Hash is okay, right folks?

I'd be fine with just Hash.  OpenStruct is cool and all, but if this
is to be used for query parameters you're going to have to be really
paranoid about key names (e.g. imagine a query with a variable named
new_ostruct_member).

-mental



More information about the Camping-list mailing list