Class: IceNine::Freezer::Hash

Inherits:
Object show all
Defined in:
lib/ice_nine/freezer/hash.rb,
lib/ice_nine/freezer/hash/state.rb

Overview

A freezer class for handling Hash objects

Defined Under Namespace

Classes: State

Constant Summary

Constants inherited from IceNine::Freezer

BasicObject

Class Method Summary collapse

Methods inherited from IceNine::Freezer

[], const_lookup, deep_freeze, deep_freeze!

Class Method Details

.guarded_deep_freeze(hash, recursion_guard) ⇒ Hash

Deep Freeze a Hash

Examples:

hash = IceNine::Freezer::Hash.deep_freeze('a' => '1', 'b' => '2')
hash.keys.select(&:frozen?)    # => ['a', 'b']
hash.values.select(&:frozen?)  # => ['1', '2']

Parameters:

Returns:



20
21
22
23
24
25
# File 'lib/ice_nine/freezer/hash.rb', line 20

def self.guarded_deep_freeze(hash, recursion_guard)
  super
  default = hash.default_proc || hash.default
  Freezer.guarded_deep_freeze(default, recursion_guard)
  freeze_key_value_pairs(hash, recursion_guard)
end