On Jul 31, 12:42=A0pm, Justin Collins <justincoll... / ucla.edu> wrote:
> OpenStruct might be what you want:http://ruby-doc.org/core/classes/OpenSt=
ruct.html

I appreciate the thought, but it kind of doesn't matter what I might
want. I have to stick with the crap I'm building on because I don't
feel like rewriting a gem.

In case anyone is wondering, the 'solution' (as in it works but I
don't recommend it) with help from Aaron "tenderlove" Patterson, goes
something like this.

    Thing =3D Struct.new(:a, :b, :c) do
      def some_thing
      end
    end

    class Thing
      attr_accessor :d

      alias_method :old_brackets, :[]
      def [](m)
        if m.to_s =3D=3D 'd'
          self.d
        else
          old_brackets(m)
        end
      end

      alias_method :old_brackets_equal, :[]=3D
      def []=3D(m, v)
        if m.to_s =3D=3D 'd'
          self.d =3D v
        else
          old_brackets_equal(m, v)
        end
      end
    end

Tell me that doesn't make you unhappy.

--
-yossef