Iñaki Baz Castillo
3/30/2009 9:18:00 AM
2009/3/30 F. Senault <fred@lacave.net>:
>
> It depends on what exactly you are trying to do with your hash. =C2=A0If =
you
> need to access to a few well known headers in your code, use symbols for
> those and add another pseudo-header for the rest of the info :
>
> USEFUL_HEADERS =3D [ :from, :to, :"x-mailer" ]
>
> headers =3D {
> =C2=A0:from =3D> "alice@aaa.com",
> =C2=A0:to =3D> "bob@bbb.com",
> =C2=A0:"x-mailer" =3D> "Pegasus Mail for Windows (4.50 PB1)",
> =C2=A0:"_custom" =3D> {
> =C2=A0 =C2=A0"x-custom-header-1" =3D> "Hi there",
> =C2=A0 =C2=A0"x-spam-scanned" =3D> "Of course"
> =C2=A0}
> }
>
> (Now, you'll lose time at the parse step. =C2=A0Again, depending on what
> you're trying to do, it may be efficient if each mail is parsed one time
> and, then, each header is accessed a lot of times.)
Thanks, but I prefer to store all the headers in a transparent way so
accessing to a core and well known header is the same as accesing to a
custom and never seen header:
headers[:from]
header[:"x-custom-headers"]
This is, in the transport/parsing layer I cannot know which headers
will be important or not in the "application" layer.
A way to check if a Symbol already exist would be enought for me, but
it doesn't work:
To know all the current Symbols I can inspect Symbol.all_symbols, but
if I want to check a Symbol:
Symbol.all_symbols.include?(:new_symbol)
this will always return true since :new_symbol is automatically added XDDD
Thanks.
--=20
I=C3=B1aki Baz Castillo
<ibc@aliax.net>