From: Intransition Date: 2012-02-21T12:46:01+09:00 Subject: Protecting internal table ------=_Part_1073_17282701.1329795958759 Content-Type: multipart/alternative; boundary="----=_Part_1074_23193238.1329795958760" ------=_Part_1074_23193238.1329795958760 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit The OpenStruct class stores values in an internal hash `@table`. For use with Marshal, it exposes this table via the method: def marshal_dump @table end Seems to me that this exposure should be protected to prevent people from modifying it in place, particularly adding non-symbol keys. But what is the proper way of doing this? Should the result be frozen? Perhaps #dup? Or both? Or am I being over concerned and we shouldn't bother? ------=_Part_1074_23193238.1329795958760 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit The OpenStruct class stores values in an internal hash `@table`. For use with Marshal, it exposes this table via the method:

    def marshal_dump
      @table
    end

Seems to me that this exposure should be protected to prevent people from modifying it in place, particularly adding non-symbol keys.

But what is the proper way of doing this? Should the result be frozen? Perhaps #dup? Or both? Or am I being over concerned and we shouldn't bother?


------=_Part_1074_23193238.1329795958760-- ------=_Part_1073_17282701.1329795958759--