Module: RMExtensions::ObjectExtensions::Util
- Defined in:
- lib/motion/util.rb
Instance Method Summary collapse
-
#rmext_assert_main_thread! ⇒ Object
Raises an exception when called from a thread other than the main thread.
- #rmext_assign_debug_labels_to_ivars! ⇒ Object
-
#rmext_ivar(*args) ⇒ Object
Shortcut to instance_variable_get and instance_variable_get: 1 arg for instance_variable_get 2 args for instance_variable_set.
- #rmext_nil_instance_variables! ⇒ Object
Instance Method Details
#rmext_assert_main_thread! ⇒ Object
Raises an exception when called from a thread other than the main thread. Good for development and experimenting.
17 18 19 |
# File 'lib/motion/util.rb', line 17 def rmext_assert_main_thread! raise "This method must be called on the main thread." unless NSThread.currentThread.isMainThread end |
#rmext_assign_debug_labels_to_ivars! ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/motion/util.rb', line 42 def rmext_assign_debug_labels_to_ivars! ivars = [] + instance_variables while ivar = ivars.pop val = instance_variable_get(ivar) val.rmext_ivar(:debug_label, ivar) end true end |
#rmext_ivar(*args) ⇒ Object
Shortcut to instance_variable_get and instance_variable_get: 1 arg for instance_variable_get 2 args for instance_variable_set
24 25 26 27 28 29 30 31 32 |
# File 'lib/motion/util.rb', line 24 def rmext_ivar(*args) if args.size == 1 instance_variable_get("@#{args[0]}") elsif args.size == 2 instance_variable_set("@#{args[0]}", args[1]) else raise "rmext_ivar called with invalid arguments: #{args.inspect}" end end |
#rmext_nil_instance_variables! ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/motion/util.rb', line 34 def rmext_nil_instance_variables! ivars = [] + instance_variables while ivar = ivars.pop instance_variable_set(ivar, nil) end true end |