Module: Multiton::Mixin

Defined in:
lib/multiton/mixin.rb

Overview

Mixin adds appropriate behavior to multiton instances.

Instance Method Summary collapse

Instance Method Details

#_dump(_level) ⇒ Object

call-seq:

_dump(_level) => string

Serializes the instance as a string that can be reconstituted at a later point. The parameter _level is not used, but it is needed for marshalling to work correctly.

Returns a string representing the serialized multiton instance.



13
14
15
# File 'lib/multiton/mixin.rb', line 13

def _dump(_level)
  self.class.instance_variable_get(:@__multiton_instances).key self
end

#cloneObject

call-seq:

clone

Raises a TypeError since multiton instances can not be cloned.

Never returns.

Raises:

  • (TypeError)


24
25
26
# File 'lib/multiton/mixin.rb', line 24

def clone
  raise TypeError, "can't clone instance of multiton `#{self.class.name}`"
end

#dupObject

call-seq:

dup

Raises a TypeError since multiton instances can not be duplicated.

Never returns.

Raises:

  • (TypeError)


35
36
37
# File 'lib/multiton/mixin.rb', line 35

def dup
  raise TypeError, "can't dup instance of multiton `#{self.class.name}`"
end