Module: Adamantium::Mutable

Defined in:
lib/adamantium/mutable.rb

Overview

Module fake frozen object

This behavior sometimes is needed when a mutable object needs to be referenced in an inmutable object tree.

If you have to use memoize :foo, freezer: :noop to often you might want to include this module into your class.

Use wisely! A rule of thumb only a tiny fraction of your objects typically deserves this.

Instance Method Summary collapse

Instance Method Details

#freezeself

Noop freezer

Examples:

class DoesNotGetFrozen
  include Adamantium::Mutable
end

instance = DoesNotGetFrozen
instance.freeze # => instance

Returns:

API:

  • public



32
33
34
# File 'lib/adamantium/mutable.rb', line 32

def freeze
  self
end

#frozen?true

Test if object is frozen

Examples:

class DoesNotGetFrozen
  include Adamantium::Mutable
end

instance = DoesNotGetFrozen
instance.frozen? # => true

Returns:

API:

  • public



50
51
52
# File 'lib/adamantium/mutable.rb', line 50

def frozen?
  true
end