Class: RMExtensions::OnDeallocInternalObject

Inherits:
Object
  • Object
show all
Defined in:
lib/motion/deallocation.rb

Overview

Used internally by rmext_on_dealloc. The idea is this object is added to the object we want to watch for deallocation. When the object we want to watch is about to dealloc, this object will dealloc first, so we can execute the block. the object it follows is kept only as a weak reference to not create a retain cycle.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block.



36
37
38
# File 'lib/motion/deallocation.rb', line 36

def block
  @block
end

#descriptionObject

Returns the value of attribute description.



36
37
38
# File 'lib/motion/deallocation.rb', line 36

def description
  @description
end

Class Method Details

.create(description, obj, block) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/motion/deallocation.rb', line 38

def self.create(description, obj, block)
  x = new
  x.description = description
  x.obj = obj
  x.block = block
  x
end

Instance Method Details

#deallocObject



45
46
47
48
49
50
51
52
# File 'lib/motion/deallocation.rb', line 45

def dealloc
  # p "dealloc OnDeallocInternalObject #{description}"
  if block
    block.call(obj)
    self.block = nil
  end
  super
end