Class: Kernel

Inherits:
Object
  • Object
show all
Defined in:
motion-prime/core_ext/kernel.rb

Instance Method Summary collapse

Instance Method Details

#class_name_without_kvoObject



6
7
8
# File 'motion-prime/core_ext/kernel.rb', line 6

def class_name_without_kvo
  self.class.name.gsub(/^NSKVONotifying_/, '')
end

#clear_instance_variables(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'motion-prime/core_ext/kernel.rb', line 18

def clear_instance_variables(options = {})
  ivars = self.instance_variables
  excluded_ivars = Array.wrap(options[:except]).map(&:to_s)
  clear_block = proc { |ivar|
    next if excluded_ivars.include?(ivar[1..-1])
    self.instance_variable_set(ivar, nil)
  }.weak!
  ivars.each(&clear_block)
end

#pp(*attrs) ⇒ Object



2
3
4
# File 'motion-prime/core_ext/kernel.rb', line 2

def pp(*attrs)
  NSLog([*attrs].map(&:inspect).join(' '))
end

#strong_refObject



14
15
16
# File 'motion-prime/core_ext/kernel.rb', line 14

def strong_ref
  self
end

#weak_refObject



10
11
12
# File 'motion-prime/core_ext/kernel.rb', line 10

def weak_ref
  WeakRef.new(self)
end