--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 = 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=>value pairs.
--
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
cr
-----END PGP SIGNATURE-----
--J2SCkAp4GZ/dPZZf--