Class: Hash
Overview
Add fully_freeze support to the hash class.
Instance Method Summary collapse
-
#fully_freeze(progress = {}) ⇒ Object
Do fully_freeze the hash.
-
#fully_frozen?(progress = {}) ⇒ Boolean
Is this hash fully_frozen?.
Instance Method Details
#fully_freeze(progress = {}) ⇒ Object
Do fully_freeze the hash.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fully_freeze/hash.rb', line 7 def fully_freeze(progress={}) progress[object_id] = freeze each_pair do |key, value| key.fully_freeze(progress) unless progress[key.object_id] value.fully_freeze(progress) unless progress[value.object_id] end self end |
#fully_frozen?(progress = {}) ⇒ Boolean
Is this hash fully_frozen?
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fully_freeze/hash.rb', line 19 def fully_frozen?(progress={}) return false unless frozen? progress[object_id] = self each_pair do |key, value| return false unless progress[key.object_id] || key.fully_frozen?(progress) return false unless progress[value.object_id] || value.fully_frozen?(progress) end true end |