From: Chad Perrin Date: 2011-07-22T06:17:36+09:00 Subject: attr_accessor for hash keys --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Is there a way to use attr_accessor, or something like it (without writing it from scratch), for hash keys? For instance: class Foo attr_accessor :bar[:one], :bar[:two] def initialize(bar) @bar =3D bar end end Obviously, :bar[:one] and :bar[:two] won't work, because symbols don't have [] methods, but that should illustrate the general gist of what I'm asking (I hope). I'd just like to avoid the clutter of writing a bunch of basic accessors myself, the long way, in a class definition where I'd like to keep all the data in a hash but have direct accessor method ways to work with specific key=3D>value pairs. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --J2SCkAp4GZ/dPZZf Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk4ok4MACgkQ9mn/Pj01uKXF4gCg7KcvkKSRKfwdVQt3t04MkIOW vJoAn2Ez7rNLNlLzLexOH14USbK3ov8G =Nucr -----END PGP SIGNATURE----- --J2SCkAp4GZ/dPZZf--