Class: IceNine::Freezer

Inherits:
Object
  • Object
show all
Defined in:
lib/ice_nine/freezer.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/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

Overview

The default class that handles freezing objects

Direct Known Subclasses

NoFreeze, Object

Defined Under Namespace

Classes: Array, FalseClass, Hash, Module, NilClass, NoFreeze, Numeric, Object, Range, Rubinius, Struct, Symbol, TrueClass

Constant Summary collapse

BasicObject =

Object

Object

Class Method Summary collapse

Class Method Details

.[](mod) ⇒ Class<Freezer>

Look up the Freezer descendant by object type

Examples:

freezer_class = IceNine::Freezer[mod]

Parameters:

Returns:


27
28
29
# File 'lib/ice_nine/freezer.rb', line 27

def self.[](mod)
  @freezer_cache[mod]
end

.const_lookup(namespace) ⇒ Module?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Look up a constant in the namespace

Parameters:

  • namespace (String)

Returns:

  • (Module)

    returned if a matching constant is found

  • (nil)

    returned if no matching constant is found


86
87
88
# File 'lib/ice_nine/freezer.rb', line 86

def self.const_lookup(namespace)
  const_get(namespace) if const_defined?(namespace, nil)
end

.deep_freeze(object) ⇒ Object

Deep freeze an object with a particular Freezer

Parameters:

Returns:

See Also:


40
41
42
# File 'lib/ice_nine/freezer.rb', line 40

def self.deep_freeze(object)
  guarded_deep_freeze(object, RecursionGuard::ObjectSet.new)
end

.deep_freeze!(object) ⇒ Object

Deep freeze an object with a particular Freezer

Parameters:

Returns:

See Also:


53
54
55
# File 'lib/ice_nine/freezer.rb', line 53

def self.deep_freeze!(object)
  guarded_deep_freeze(object, RecursionGuard::Frozen.new)
end

.guarded_deep_freeze(object, recursion_guard) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deep freeze an object with a particular Freezer and RecursionGuard

Parameters:

Returns:


98
99
100
101
102
# File 'lib/ice_nine/freezer.rb', line 98

def self.guarded_deep_freeze(object, recursion_guard)
  recursion_guard.guard(object) do
    Freezer[object.class].guarded_deep_freeze(object, recursion_guard)
  end
end