Module: Immutability::WithMemory::ClassMethods Private

Defined in:
lib/immutability/with_memory.rb

Overview

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

Methods to be added to class, that included the ‘Immutability` module

Instance Method Summary collapse

Instance Method Details

#new(*args, &block) ⇒ 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.

Reloads instance’s constructor to add version and parent and make the whole instance immutable

Parameters:

Returns:



29
30
31
32
33
34
35
36
# File 'lib/immutability/with_memory.rb', line 29

def new(*args, &block)
  instance = allocate.tap do |obj|
    obj.__send__(:initialize, *args, &block)
    obj.instance_variable_set(:@version, 0)
    obj.instance_variable_set(:@parent, nil)
  end
  IceNine.deep_freeze(instance)
end