From: "matz (Yukihiro Matsumoto)" Date: 2013-08-31T14:38:13+09:00 Subject: [ruby-core:56914] [ruby-trunk - Feature #2509][Rejected] Recursive freezing? Issue #2509 has been updated by matz (Yukihiro Matsumoto). Status changed from Assigned to Rejected Object#deep_freeze means you can freeze everything recursively, by definition. But what if the target object accidentally refers objects that are not supposed to be frozen (e.g. classes)? That would be disaster. So, I'd rather prefer limited deep_freeze e.g. module DeepFreezable def deep_freeze self.each_reference do |o| o.deep_freeze end end end So I reject this Object#deep_freeze idea. Matz. ---------------------------------------- Feature #2509: Recursive freezing? https://bugs.ruby-lang.org/issues/2509#change-41465 Author: marcandre (Marc-Andre Lafortune) Status: Rejected Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: next minor =begin I like freezing my constants, config files I read, etc... I believe it is the typical use case for #freeze. In all theses cases, what I really want to do is freeze everything. There is often no easy way to do this (e.g. for config files), or else one must explicitly call freeze a bunch of times, like: DEFAULT_SEND_FILE_OPTIONS = { :type => 'application/octet-stream'.freeze, :disposition => 'attachment'.freeze, }.freeze It would be very nice if there was an easy way to freeze recursively arrays, hashes, etc... A solution would be for #freeze to accept a level argument (similar to flatten, but the default being 1), or alternatively a boolean one (recursive = false). Should I write a patch for this feature request? Thanks, Marc-Andr�� =end -- http://bugs.ruby-lang.org/