Module: IceNine

Defined in:
lib/ice_nine.rb,
lib/ice_nine/freezer.rb,
lib/ice_nine/version.rb,
lib/ice_nine/freezer/hash.rb,
lib/ice_nine/freezer/array.rb,
lib/ice_nine/freezer/range.rb,
lib/ice_nine/freezer/module.rb,
lib/ice_nine/freezer/object.rb,
lib/ice_nine/freezer/struct.rb,
lib/ice_nine/freezer/symbol.rb,
lib/ice_nine/core_ext/object.rb,
lib/ice_nine/freezer/numeric.rb,
lib/ice_nine/freezer/rubinius.rb,
lib/ice_nine/freezer/nil_class.rb,
lib/ice_nine/freezer/no_freeze.rb,
lib/ice_nine/freezer/hash/state.rb,
lib/ice_nine/freezer/true_class.rb,
lib/ice_nine/freezer/false_class.rb,
lib/ice_nine/support/recursion_guard.rb

Overview

Base IceNine module

Defined Under Namespace

Modules: CoreExt Classes: Freezer, RecursionGuard

Constant Summary collapse

VERSION =

Gem version

'0.11.2'.freeze

Class Method Summary collapse

Class Method Details

.deep_freeze(object) ⇒ Object

Deep Freeze an object

Examples:

object = IceNine.deep_freeze(object)

Parameters:

  • object (Object)

Returns:

  • (Object)


37
38
39
# File 'lib/ice_nine.rb', line 37

def self.deep_freeze(object)
  Freezer.deep_freeze(object)
end

.deep_freeze!(object) ⇒ Object

Deep Freeze an object

This method uses a faster algorithm that will assume objects that are ‘frozen?` do not need to be frozen deeply. Use this method when `object` contains no shallowly frozen objects that need deep freezing.

Examples:

IceNine.deep_freeze!(['a', 'b']).map(&:frozen?) # [true, true]
IceNine.deep_freeze!(['a', 'b'].freeze).map(&:frozen?) # [false, false]

Parameters:

  • object (Object)

Returns:

  • (Object)


58
59
60
# File 'lib/ice_nine.rb', line 58

def self.deep_freeze!(object)
  Freezer.deep_freeze!(object)
end