class Hash

Add fully_freeze support to the hash class.

Public Instance Methods

fully_freeze(progress={}) click to toggle source

Do fully_freeze the hash.

# 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={}) click to toggle source

Is this hash fully_frozen?

# 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